Git Reference ยท Configuration Options
rerere.enabled setting
Reference for rerere.enabled and rerere.autoUpdate: how Git records conflict resolutions and replays them, with a runnable example and the rr-cache folder.
rerere stands for "reuse recorded resolution". When it is enabled, Git remembers how you resolved a merge conflict and applies the same resolution automatically the next time it meets the same conflict. That matters for long-lived topic branches that you merge repeatedly, for rebases that replay the same commits more than once, and when you test-merge a branch and throw the result away.
The feature is off by default, even though its files cost almost nothing. Enable it once, globally, and forget about it until the day it saves you from fixing the same conflict for the fifth time.
git config --global rerere.enabled true git config --global rerere.autoUpdate true # also stage the replayed result
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
git config rerere.enabled <true | false> git config rerere.autoUpdate <true | false> git rerere # record, replay or update as needed git rerere status # paths rerere is tracking git rerere diff # resolution so far, compared with the conflict git rerere forget <path> # discard the recorded resolution for a path git rerere clear # drop state for unresolved paths git rerere gc # prune old records
| Setting | Description |
|---|---|
rerere.enabled |
Turns the feature on. If unset, rerere is on only when the directory .git/rr-cache exists. |
rerere.autoUpdate |
After a recorded resolution has been replayed, add the file to the index automatically. The default false leaves the file modified but unstaged so you can inspect it. |
Where it stores data: .git/rr-cache/<hash>/ contains a preimage (the conflicted file) and a postimage (your resolution). The hash identifies the conflict by the content of its hunks, not by file name or commit.
Usage notes
- Matching is by conflict text. If the two sides of the conflict are identical to a recorded one, the resolution is applied, even on a different branch, a different commit, or in a rebase. If anything on either side changes, it counts as a new conflict.
- Check what was replayed. A replayed resolution is only as correct as when you recorded it. Git prints
Resolved 'file' using previous resolution.and the file contains no conflict markers, so run your tests. The merge is still stopped for you to commit. - Fix a bad recording with
git rerere forget <path>, while the conflict is in progress (usegit checkout --merge <path>to bring the markers back first), and resolve again. - It works with rebase, cherry-pick, revert and
git merge, which is why teams use it to rebase a long branch many times. Test merges withgit merge --no-commitalso record resolutions for later. - Sharing:
rr-cacheis local. Teams that want to share resolutions can sync the directory by hand, but most simply rely on each person recording their own. - Cleanup:
git gcrunsrerere gc, removing unresolved records after 15 days and resolved ones after 60. Tune this withgc.rerereResolvedandgc.rerereUnresolved. - Not a merge strategy. It does not decide anything for you the first time; it only remembers your decision.
Related
git rerere,merge.*,rebase.*,git merge- Lessons: Merge conflicts, Rebase