🔀 Git: Fix rerere Replaying a Resolution You Already Reverted
With rerere.enabled turned on, Git records how you resolved a merge conflict the first time and automatically reapplies that exact same resolution the next time an identical conflict shows up — which is a genuine time-saver during a long interactive rebase with repeated conflicts, but it has no concept of “I changed my mind about that resolution later.” If you resolve a conflict once, realize partway through the rebase that the resolution was wrong, and manually fix it differently in a later step, rerere’s recorded resolution record for that exact conflict pattern doesn’t get updated — it’s still sitting in .git/rr-cache with the original (now-wrong) answer, ready to silently reapply itself the next time Git sees that same conflicting hunk, including on a completely different branch or a rebase run weeks later.
🔎 The Problem
$ git rebase main
Auto-merging src/config.js
CONFLICT (content): Merge conflict in src/config.js
<- you resolve this by keeping YOUR side
# ...three commits later in the same rebase, you realize that
# resolution was wrong and manually fix config.js differently
# in a later commit instead of going back to redo the conflict
# Weeks later, a different rebase hits the exact same conflict pattern:
$ git rebase main
Auto-merging src/config.js
Resolved 'src/config.js' using previous resolution.
<- rerere silently reapplies the FIRST (wrong, already-superseded)
resolution, with no conflict markers shown and no prompt to review it
✅ Fix: Clear or Update the Recorded Resolution When You Change Your Mind
- Run
git rerere forget <path>for any file whose conflict resolution you end up changing later in the same rebase, which removes the stale recorded resolution so the next identical conflict shows real conflict markers again instead of silently auto-resolving to the old answer. - Review what rerere is about to auto-apply with
git rerere diffbefore trusting an auto-resolved file, especially on a long-lived branch where conflict patterns recorded weeks or months ago might no longer reflect the current, correct resolution. - Periodically clear old entries with
git rerere gc(or manually prune.git/rr-cache) on repositories where conflict resolutions have genuinely changed over the project’s history, since rerere has no built-in expiration and will happily keep replaying a years-old resolution forever if the exact same conflict pattern ever recurs.
🚨 Why This Is Dangerous
- An auto-resolved conflict shows no markers and asks for no review, so a stale rerere resolution silently reintroducing an already-reverted mistake can slip straight into a commit and through code review, since the diff looks like a clean, deliberate merge rather than a conflict that was ever in question.
rerere remembers how you resolved a conflict, not whether you were right — and it will keep being confidently, silently wrong until you explicitly tell it to forget.




