You have stacked branches (A, B, C) and need to rebase the whole stack after A changes.
AdvancedScenarioRebase, Cherry-pick and History Rewriting
Answer
Situation read → Rebasing only the top branch leaves A and B pointing at old commits.
What I'd do →
- Check out the top branch C.
git rebase -i --update-refs origin/main(Git 2.38+); the todo list updates A and B pointers too.- Push all:
git push --force-with-lease origin A B C. - Or use tooling such as
gh stack-style helpers, Graphite or ghstack for larger stacks.
Why → --update-refs moves every branch whose tip is inside the rebased range.
Interview tip → Stacks keep PRs small but need discipline: merge bottom-up and retarget as you go.
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.IntermediateBranch B was built on top of branch A. A was squash-merged into `main`, and now B shows A's commits again.IntermediateDuring review you get ten small change requests on old commits. How do you apply them cleanly?Intermediate