Interview Prep/Git & GitHub/Merge and Rebase Problems

After `git pull` on a branch someone rebased, your history contains every commit twice.

IntermediateTroubleshootingMerge and Rebase Problems
Answer

Likely causes → Remote history was rewritten, so the old commits (yours) and the new ones (rewritten) have different SHAs. A merge pull combined both lines.

Diagnose →

git log --oneline --graph -20
git log --cherry-pick --left-right --oneline HEAD...origin/feature

Fix → If you have no local work: git reset --hard origin/feature. With local commits: git rebase --onto origin/feature <old-remote-tip> feature (find the old tip in git reflog show origin/feature). Undo the merge first with git reset --hard ORIG_HEAD.

Prevent → Use git pull --rebase on branches that might be rewritten, and tell the team when you force-push.

All Git & GitHub questions Roadmap: Git & GitHub

More on Merge and Rebase Problems