patterngitTip
git rerere: reuse recorded conflict resolutions
Viewed 0 times
git rererereuse resolutionconflict resolution cacherepeated conflictsrebase conflicts
Problem
When rebasing a long-lived feature branch onto main repeatedly, the same conflicts occur and require manual resolution each time.
Solution
Enable git rerere to record and automatically reuse conflict resolutions:
# Enable globally
git config --global rerere.enabled true
Once enabled:
# See recorded resolutions
git rerere status
git rerere diff # preview what rerere will apply
# Forget a bad resolution
git rerere forget path/to/file.js
# Enable globally
git config --global rerere.enabled true
Once enabled:
- First time: resolve a conflict manually
- Git records the resolution in .git/rr-cache/
- Next time the same conflict occurs: Git applies it automatically
# See recorded resolutions
git rerere status
git rerere diff # preview what rerere will apply
# Forget a bad resolution
git rerere forget path/to/file.js
Why
rerere = 'Reuse Recorded Resolution'. Git hashes the conflict region, stores your resolution, and replays it when the same conflict pattern appears. Especially powerful during iterative rebases.
Gotchas
- rerere only activates for the same conflict context — if surrounding code changes significantly, the hash won't match
- A bad resolution will be reused until you
git rerere forgetit — always verify auto-resolved conflicts - rr-cache is local and not shared with teammates — each developer builds their own cache
Code Snippets
Setting up and using git rerere
# Enable rerere globally
git config --global rerere.enabled true
# Check recorded resolutions
git rerere status
# See what rerere would apply
git rerere diff
# Remove a bad remembered resolution
git rerere forget src/payments.js
# After rerere auto-resolves, verify and stage
git add src/payments.js
git rebase --continueContext
Long-lived feature branches that are repeatedly rebased onto an actively developed main branch
Revisions (0)
No revisions yet.