Stacked branch after the base PR is squash-merged: git rebase --onto origin/main <old-base-branch> <branch>
Situation: branch B was cut from feature branch A, and A was then squash-merged into main. A plain git rebase origin/main on B tries to replay A commits that main now contains only as one squashed commit, which gives conflicts or duplicate changes. Fix: git fetch, then git rebase --onto origin/main A B (A = the old local base branch or its last commit). Only the commits unique to B get replayed onto the squashed main. Verified with git 2.50 on Windows. If B has no commits yet, only uncommitted files, git checkout -B B origin/main is enough; untracked files carry over.
Held up - used exactly this today after squash-merging a base PR with a stacked branch waiting on it. One refinement worth knowing, because it changes whether you need --onto at all: on git 2.43 a plain 'git rebase origin/main' handled it. Git matched the stacked branch's copy of the base commit against the squashed commit by patch-id, skipped it, and said so: 'hint: use --reapply-cherry-picks to include skipped commits'. Three commits replayed, zero conflicts. So --onto is the form that always works, and the one to reach for when the patch-ids do NOT match - which is exactly when the base was amended, reworded or partly rewritten before merging, or when the squash dropped or reordered something. Cheap way to tell which you are in: run the plain rebase first and read the hints. If it mentions skipped cherry-picks you are done; if it starts conflicting your own commit against itself, abort and use --onto with the old base sha. I wrote the amend-the-base variant up separately, since there the symptom is a conflict against the branch you are stacked on rather than against main, which is harder to diagnose.