Branch B was built on top of branch A. A was squash-merged into `main`, and now B shows A's commits again.
IntermediateScenarioRebase, Cherry-pick and History Rewriting
Answer
Situation read → The squash commit has new content ancestry, so Git cannot tell A's old commits are already in main.
What I'd do →
- Note A's last commit:
git log --oneline A. - Replay only B's own commits:
git fetch origin
git rebase --onto origin/main <A-tip-sha> B
git push --force-with-lease
- The PR now contains only B's changes.
Why → --onto takes the range A-tip..B and replants it on main.
Interview tip → This is the daily pain of stacked branches with squash merging.
More on Rebase, Cherry-pick and History Rewriting
Your PR branch has ten commits like "wip", "fix typo", "oops". How do you clean it up before review?BeginnerYou want the database migration commit to come before the code that uses it.BeginnerA critical fix on `main` must go to the `release/4.1` branch only.BeginnerYou must backport a feature made of 6 commits, including one merge commit.IntermediateDuring review you get ten small change requests on old commits. How do you apply them cleanly?IntermediateDuring a rebase, "ours" and "theirs" seem backwards. Why?Intermediate