Git Rerere: The Secret Merge Feature
NeuralNine ·2026-06-29 ·1 min read
Summary written by us from the video's transcript. The video, and everything in it, is NeuralNine's work.
Learn how Git’s rerere feature records and reuses merge conflict resolutions to automate repeated merges.
Takeaways
- Enable rerere with `git config rerere.enabled true` to save time on recurring merge conflicts.
- Git records the exact conflict text and surrounding context; identical conflicts are auto‑resolved on later merges.
- The order of conflicting changes is irrelevant—rerere treats swapped values as the same conflict.
- Different surrounding code prevents automatic reuse, so ensure contexts match for rerere to work.
- Resolving a conflict differently updates the stored resolution, affecting future automatic merges.
What is Git rerere
Git rerere stands for *reuse recorded resolution*. It automatically reapplies a conflict resolution that you have already performed, saving you from fixing the same merge conflict repeatedly.
Enabling rerere
Activate it with `git config rerere.enabled true`. The setting can be applied locally in a repository or globally for all Git projects.
Basic workflow demonstration
Create a repo, add a file (e.g., *main.py*), commit and push it on *main*.
Create a branch (F1), change the file’s value to `0`, commit and push. Switch back to *main*, change the same line to `100`, commit and push. Merging F1 into *main* produces a conflict; resolve it manually (e.g., set the value to `50`), stage, run `git merge --continue`, and push. Git records this resolution.
Automatic reuse on subsequent conflicts
Repeat the same pattern with another file (*main2.py*) and branch F2. When merging, Git automatically applies the previously recorded resolution (`50`) without manual intervention.
The order of changes (zero vs. hundred) does not matter; rerere treats them as the same conflict and resolves it identically.
When rerere does *not* apply
If the surrounding context of the conflicted lines differs—e.g., additional lines before or after—the conflict is considered new, and rerere will not auto‑resolve it. This was shown with *main4.py*, where a different surrounding print statement prevented automatic resolution.
Updating recorded resolutions
If you resolve a conflict differently (e.g., choosing `40` instead of `50`), Git records the new outcome. Future identical conflicts will be resolved to the latest recorded value, as demonstrated with *main5.py*.