Interview Prep/Git & GitHub/Merge and Rebase Problems

A rebase of a branch with merge commits keeps replaying the same conflicts and resurrects old changes.

AdvancedTroubleshootingMerge and Rebase Problems
Answer

Likely causes → Default rebase flattens merge commits and re-applies every commit from both sides, so earlier hand-resolved conflicts reappear, and changes that were reverted can come back.

Diagnose →

git log --oneline --graph --merges origin/main..HEAD
git rev-list --merges --count origin/main..HEAD

Fix → Abort. Either keep the topology with git rebase --rebase-merges origin/main, or avoid rebasing: git merge origin/main. Another option is squash first (git reset --soft $(git merge-base HEAD origin/main), recommit) and rebase one commit. Enable rerere to remember resolutions.

Prevent → Do not merge main into a branch you plan to rebase; rebase it from the start.

All Git & GitHub questions Roadmap: Git & GitHub

More on Merge and Rebase Problems