Sub topic 12
Sharing resolutions and what rerere cannot do
This chapter assumes you have enabled rerere.enabled, know that recorded resolutions live in .git/rr-cache, and have seen rerere reuse a resolution in a merge or rebase.
Recorded resolutions stay in one clone
The .git/rr-cache directory is part of your local repository data. git push, git fetch, and git clone do not transfer it. If you resolve a conflict on your laptop, a teammate who hits the same conflict resolves it again by hand. A fresh clone of your own repository starts with an empty cache too.
Ways to share a cache
Git has no built-in command for sharing resolutions. You can copy the directory yourself. Each subdirectory of .git/rr-cache is named by a hash of the conflict, so the same conflict in another clone maps to the same name.
# In the clone that has the resolutions: export the cache
mkdir -p /shared/rr-cache
cp -R .git/rr-cache/. /shared/rr-cache/
# In another clone: import it
mkdir -p .git/rr-cache
cp -R /shared/rr-cache/. .git/rr-cache/You can also replace .git/rr-cache with a symlink to a shared directory, so several working copies on one machine use the same cache. A common team approach is to keep the cache in its own small repository and pull it into each clone.
Sharing carries three risks:
- A wrong resolution spreads to everyone who imports it. Use
git rerere forgetin each clone that received it. - Resolutions that apply to a branch someone has since rewritten are clutter, but harmless.
- Expiry works per clone.
git gcremoves old entries based ongc.rerereResolvedandgc.rerereUnresolved, so a shared directory is pruned by whichever clone runsgit gcfirst.
What rerere cannot do
rerere reuses text. It has no understanding of your code, which sets these limits.
| Limit | What happens |
|---|---|
| The conflict text differs | The match depends on the conflicting hunks. If either side changed even one character inside the conflict, Git sees a new conflict and you resolve it again. |
| No conflict markers | rerere only handles content conflicts that produce markers in a text file. It does not handle binary files, delete/modify conflicts, or rename conflicts. |
| Semantic conflicts | Two changes that merge cleanly but break the program together never produce a conflict, so rerere never sees them. |
| Reused but wrong | A reused resolution is applied to the working tree, not checked. The code may no longer compile or pass tests in the new context. |
| Cache missing | A new clone, a deleted cache, or an expired entry means no recorded resolution exists. |
The last-but-one row is the most common surprise. The conflict looks identical, but the surrounding code changed, so the old resolution produces a result that is textually fine and logically broken. Build and run your tests after every merge that rerere helped with. Review the file even when rerere.autoupdate has staged it, because staging removes the signal that something still needs your attention.
A quick check before trusting a reused resolution
git merge feature
# Look for: Resolved 'settings.txt' using previous resolution.
git rerere diff # compare the working tree with the recorded conflict
git diff # review what rerere wrote
# run your tests, then:
git add settings.txt
git commitIf the result is wrong, recreate the conflict with git checkout --merge -- settings.txt, run git rerere forget settings.txt, and resolve it again.
Exercise
A teammate pushes a branch to the shared remote. You merge it into your branch and hit a conflict you resolved last week in your own clone, but your teammate's clone does not reuse your resolution when they run the same merge. Give two reasons this can happen and one fix.
Show answer
First, rr-cache is local and is not sent by push or fetch, so the teammate's clone has no record of your resolution. Second, they may not have rerere.enabled set, or the conflicting text may differ slightly on their side, which gives a different conflict hash. Fix: enable rerere in their clone and copy your .git/rr-cache directory into theirs, or share a common cache directory. Then confirm they see "Resolved ... using previous resolution".