| name | rebase-stacked-pr |
| description | Rebase a stacked PR onto main after its parent was squash-merged, using `git rebase --onto` to skip already-merged commits. Use when rebasing a stacked or dependent PR, handling a squash-merged parent PR, or recovering from empty commits or spurious conflicts after `git rebase main`. |
Rebase a stacked PR after squash-merge
This skill handles the mechanical rebase when a child PR's parent PR has been squash-merged to main. A naive git rebase main fails or produces conflicts because the child branch still contains the parent's pre-squash commits, which are logically identical to — but SHA-different from — the new squashed commit on main.
The fix is git rebase --onto main <pre-squash-parent-tip> <child-branch>, which replays only the child's own commits and skips the already-merged ones.
Do not use this skill if
- The parent PR has not yet been merged — just rebase onto the parent branch normally (
git rebase origin/parent-branch).
- The parent PR was merge-committed (not squash-merged) — a plain
git rebase main works fine in that case.
Inputs required
Before running commands, confirm:
- Parent PR number — see Finding the parent PR number.
- Child branch name — usually the current branch; verify with
git branch --show-current.
- Parent is actually merged — check with
gh pr view <PARENT_PR> --json state,mergedAt. Abort if state is not MERGED.
If the child PR description contains a "Rebase instructions" block with explicit variables, prefer those values.
Finding the parent PR number
Check the child PR description for explicit declarations first: