gotchaMajorpending
Gotcha: Git rebase can silently drop merge conflict resolution
Viewed 0 times
rerererebase conflictsmerge resolutionconflict reuserebase vs merge
Error Messages
Problem
When rebasing a branch that previously resolved merge conflicts, the conflicts reappear and previous resolution is lost.
Solution
Enable rerere to remember conflict resolutions:
When to avoid rebase:
# Enable rerere (reuse recorded resolution)
git config --global rerere.enabled true
# Now git remembers how you resolved each conflict
# When the same conflict appears during rebase, it auto-resolves
# View recorded resolutions
git rerere status # Show current conflicts being tracked
git rerere diff # Show how conflicts will be resolved
# If you resolved incorrectly, forget it
git rerere forget path/to/file
# Alternative: Use merge instead of rebase for long-lived branches
# Merges preserve conflict resolution history
# If you must rebase and conflicts are complex:
# 1. Before rebase, create a safety branch
git branch backup-before-rebase
# 2. Do the rebase
git rebase main
# 3. If it goes wrong
git rebase --abort # Cancel entirely
# OR
git reset --hard backup-before-rebase # Restore from backup
# Key insight: rebase replays commits one by one
# Each commit may re-encounter conflicts that were
# already resolved in the merge commitWhen to avoid rebase:
- Branch has been shared/pushed (others may have based work on it)
- Branch has complex merge conflict resolutions
- Branch has many commits that all touch the same files
Why
Rebase replays each commit individually. A merge commit that resolved conflicts is not replayed, so those resolutions are lost unless rerere remembers them.
Context
Git workflow with rebasing
Revisions (0)
No revisions yet.