If you have ever been stuck in a merge loop where the same conflict shows up three times across a feature branch, you already know the pain rerere solves.
rerere stands for Reuse Recorded Resolution. It been in Git since 2009. It a single config toggle, and it does exactly what it says: remembers how you resolved a conflict and auto-applies that resolution when the same conflict comes up again.
The workflow looks like this. You merge, hit a conflict, resolve it, commit. Later, you rebase that branch onto master and hit the same conflict again but Git silently resolves it for you. You run git add . and git rebase --continue without touching the file.
That it. No plugins, no external tooling, no dependencies.
Enabling it
git config --global rerere.enabled true
That the entire setup. It creates a .git/rr-cache directory locally to store recorded resolutions. The global flag means it applies to every repo you touch.
What rerere actually does
When you resolve a conflict, rerere records a diff of your resolution. The next time Git encounters an identical conflict hunk in the same file, it replays that resolution automatically. It won touch anything that does not match exactly so it safe to leave on permanently.
A few things worth knowing:
- git rerere diff shows you the current recorded resolution for a file while you in a conflicted state
- git rerere status will tell you which files have recorded resolutions
- Resolutions are stored per-file-hunk-combination, not per branch so if the same change lands in two different branches, you get both resolutions
- It works with both merges and rebases
When it actually helps
rerere shines in long-running feature branches that merge into main frequently. If you doing stacked PRs or rebasing through a CI pipeline, you hit the same conflict more than once on the same file. Instead of resolving it every time, you resolve it once and rerere handles the rest.
It also useful for teams that have recurring merge conflicts on the same files generated code, migration files, config files that multiple people touch. You resolve it once, it recorded, the next person does not have to think about it.
The gotcha
rerere won auto-commit the resolution. You still need to git add the resolved file and continue your operation. What it does is skip the actual editing step you see the conflict marked as Resolved using previous resolution and you just continue.
If you want to clear recorded resolutions, delete the .git/rr-cache directory or run git rerere forget for specific files.
That all there is to it. One command, turn it on, forget about it until it saves you from a tedious conflict resolution.
Top comments (0)