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:

bash
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.autoUpdate enabled, applying resolutions without review
  • Merge conflict changed slightly but rerere matched it to an old resolution

Step-by-Step Fix

  1. 1.Check what rerere recorded for the current conflict:
  2. 2.```bash
  3. 3.git rerere status
  4. 4.# Shows which conflicts have recorded resolutions
  5. 5.git rerere diff
  6. 6.# Shows how rerere would resolve the conflict
  7. 7.`
  8. 8.Undo the incorrect rerere resolution:
  9. 9.```bash
  10. 10.# Reset the conflicted file to its pre-rerere state
  11. 11.git checkout --conflict=merge src/utils.js
  12. 12.# This restores the conflict markers
  13. 13.`
  14. 14.Resolve the conflict manually:
  15. 15.```bash
  16. 16.# Edit the file to resolve conflicts correctly
  17. 17.vim src/utils.js
  18. 18.git add src/utils.js
  19. 19.`
  20. 20.Update the recorded resolution with the correct fix:
  21. 21.```bash
  22. 22.git rerere
  23. 23.# This records the new, correct resolution for future use
  24. 24.`
  25. 25.Clear all stale rerere records if multiple resolutions are wrong:
  26. 26.```bash
  27. 27.rm -rf .git/rr-cache/
  28. 28.# Or clear a specific conflict
  29. 29.rm -rf .git/rr-cache/<conflict-hash>/
  30. 30.`
  31. 31.Disable auto-update to review rerere resolutions before applying:
  32. 32.```bash
  33. 33.git config --global rerere.autoUpdate false
  34. 34.`

Prevention

  • Review rerere resolutions before accepting them: git rerere diff
  • Keep rerere.autoUpdate set to false to require manual confirmation
  • Periodically clean the rr-cache: git rerere gc
  • Use git config --global rerere.enabled true only 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 --check to verify no conflict markers remain after resolution
  • Test merged code thoroughly before pushing, especially when rerere was involved