Introduction
Git's rerere (reuse recorded resolution) feature automatically resolves merge conflicts based on how similar conflicts were resolved in the past. When the recorded resolution is incorrect or outdated, rerere applies the wrong fix:
git merge feature-branch
# Automatic merge conflict in src/utils.js
# Rerere: Auto resolved using previous resolution
# But the resolution is wrong for this context!The conflict markers disappear, making it easy to commit incorrect code without noticing.
Symptoms
- Merge conflict disappears without manual intervention
- Resolved code does not match the expected outcome
- Rerere applies a resolution from a different conflict
- Code that was intentionally changed gets reverted
- Difficult to detect because conflict markers are gone
Common Causes
- Rerere recorded an incorrect resolution from a rushed previous merge
- Similar conflict patterns in different files cause wrong resolution reuse
- Recorded resolution is outdated and does not fit the current code context
rerere.autoUpdateenabled, applying resolutions without review- Merge conflict changed slightly but rerere matched it to an old resolution
Step-by-Step Fix
- 1.Check what rerere recorded for the current conflict:
- 2.```bash
- 3.git rerere status
- 4.# Shows which conflicts have recorded resolutions
- 5.git rerere diff
- 6.# Shows how rerere would resolve the conflict
- 7.
` - 8.Undo the incorrect rerere resolution:
- 9.```bash
- 10.# Reset the conflicted file to its pre-rerere state
- 11.git checkout --conflict=merge src/utils.js
- 12.# This restores the conflict markers
- 13.
` - 14.Resolve the conflict manually:
- 15.```bash
- 16.# Edit the file to resolve conflicts correctly
- 17.vim src/utils.js
- 18.git add src/utils.js
- 19.
` - 20.Update the recorded resolution with the correct fix:
- 21.```bash
- 22.git rerere
- 23.# This records the new, correct resolution for future use
- 24.
` - 25.Clear all stale rerere records if multiple resolutions are wrong:
- 26.```bash
- 27.rm -rf .git/rr-cache/
- 28.# Or clear a specific conflict
- 29.rm -rf .git/rr-cache/<conflict-hash>/
- 30.
` - 31.Disable auto-update to review rerere resolutions before applying:
- 32.```bash
- 33.git config --global rerere.autoUpdate false
- 34.
`
Prevention
- Review rerere resolutions before accepting them:
git rerere diff - Keep
rerere.autoUpdateset tofalseto require manual confirmation - Periodically clean the rr-cache:
git rerere gc - Use
git config --global rerere.enabled trueonly if your team understands how rerere works - Document rerere usage in your team's Git workflow guide
- After resolving conflicts, verify the resolution matches the intended outcome
- Use
git diff --checkto verify no conflict markers remain after resolution - Test merged code thoroughly before pushing, especially when rerere was involved