What are Stacked PRs?
Stacked pull requests split one larger change into an ordered chain of dependent reviews.
Introduction
In a stacked pull-request workflow, each branch builds on the branch below it. Each pull request targets its immediate parent branch, so reviewers see the increment introduced by that layer instead of the full change from main.
This makes a large feature reviewable before every layer is complete. The cost is maintaining the dependencies as lower layers change and merge.
Understanding the Concept
A stacked pull request is one pull request in an ordered chain. The bottom layer targets main. Every higher layer targets the branch directly below it.
Definition
Stacked Pull Request
A pull request whose branch depends on another pull-request branch, forming an ordered chain of incremental changes.
Definition
Stack Root
The lowest branch in a pull-request stack, usually the only layer that targets the main branch directly.
For example:
main
└── auth/schema PR 1: auth/schema -> main
└── auth/service PR 2: auth/service -> auth/schema
└── auth/api PR 3: auth/api -> auth/service
If auth/schema changes during review, the branches above it still contain commits based on the old version. Rebasing each dependent branch in order is a restack.
Definition
Restack
The process of rebasing dependent branches in order after a lower branch or the target branch changes.
The pull requests are independently reviewable, but the branches are not independent. A higher layer cannot be merged safely until its required lower layers are available on the target branch.
Applying It in Practice
You can stack pull requests on GitHub with plain Git and the GitHub web interface. The steps below build a three-layer stack, keep it current, and merge it. The Stacked PR workflow turns them into a routine, with checks for layer boundaries and review order.
1. Create the branches in order. Branch each layer from the one below it:
git switch main
git pull --ff-only
git switch -c auth/schema
# edit and commit
git switch -c auth/service
# edit and commit
git switch -c auth/api
# edit and commit
git push -u origin auth/schema auth/service auth/api
2. Open one pull request per layer, with the right base. The base branch decides what the reviewer sees. Set it with the base drop-down in the GitHub interface, or with the GitHub CLI:
gh pr create --head auth/schema --base main
gh pr create --head auth/service --base auth/schema
gh pr create --head auth/api --base auth/service
Name the stack order in each description, so a reviewer knows which pull request to read first.
3. Restack after a lower layer changes. Review feedback on auth/schema leaves the branches above it on the old commits. Rebase each layer onto the one below it, bottom to top:
git switch auth/service
git rebase auth/schema
git switch auth/api
git rebase auth/service
git push --force-with-lease origin auth/service auth/api
When main advances, run the following commands from the top branch with Git 2.38 or later. --update-refs moves branches that point into the rebased range, except those checked out in another worktree. Check git worktree list first.
git switch auth/api
git rebase --update-refs main
git push --force-with-lease origin auth/schema auth/service auth/api
Rebase a Whole Stack With --update-refs covers the one-command form in detail. Before pushing, inspect each layer against its intended base:
git log --oneline auth/schema..auth/service
git diff auth/schema...auth/service
4. Merge the bottom pull request. Merge auth/schema into main. If you delete the branch on GitHub, check that the auth/service pull request now targets main. If you keep the remote branch, change the PR base yourself. Keep your local auth/schema branch for step 5.
5. Rebase the rest onto main. A squash or rebase merge gives the merged commits new IDs on main, so auth/service still carries the old copies. Drop them with git rebase --onto:
git fetch origin
git switch auth/service
git rebase --onto origin/main auth/schema
git push --force-with-lease
Then restack auth/api onto auth/service as in step 3. Rebase a Stacked Branch After a Squash Merge walks through why the plain rebase replays the parent's commits. Repeat steps 4 and 5 until the stack is gone.
GitHub's Built-in Stack Support
GitHub made stacked pull requests generally available on all github.com plans in October 2026. GitHub tracks the stack as a unit. Merging a pull request merges every pull request below it, and GitHub retargets and rebases the ones above. The gh stack extension for the GitHub CLI creates branches in order, rebases them, and submits the whole stack with gh stack submit:
gh extension install github/gh-stack
All branches must live in the same repository, so stacks across forks are not supported. GitHub Enterprise Server support has not shipped yet. Treq vs GitHub Stacked PRs compares the native feature with stacking done locally.
Tooling Options
The plain Git steps work, but the bookkeeping grows with every layer. Stack tools record the parent of each branch, restack in one command, and set pull-request bases for you. Best Graphite Alternatives lists the current options, and Graphite vs GitButler compares two of the most common ones. If coding agents write the layers, Treq as a Graphite alternative compares stacking local agent workspaces with stacking remote pull requests. No tool picks sound layer boundaries or resolves semantic conflicts for you.
How Treq Handles Stacks
In Treq, a stack is a chain of workspaces. A workspace can target another workspace's branch instead of the default branch. When a lower workspace changes, Treq rebases the workspaces above it onto the new target, so you skip the manual restack in step 3.
Treq also follows GitHub as it polls pull-request status. When a pull request moves to a new base, its workspace moves to that base. When the pull request below merges, the workspace above moves onto the merged workspace's own target, which covers steps 4 and 5. Fix conflicts from the lowest workspace upward, because each layer feeds the ones above it.
Stacks for Agent-Generated Code
A coding agent can produce a whole feature in one session, faster than anyone can review it. A stack keeps that output reviewable, but only if the layers come from the design, not from the finished diff.
- Plan the layers before the agent starts, and give it one layer per task: schema, then service, then API.
- Run one agent session per layer, each in its own branch or workspace, so work on the API does not rewrite the schema below it.
- Write acceptance criteria for each layer, not only for the finished feature.
- Reject a layer that carries unrelated cleanup from the agent. It makes every review above it larger.
- Re-read each layer's diff after a restack, because conflict resolution can change behavior.
Splitting a finished agent diff by file count produces layers that do not build on their own. Ask the agent to redo the work in layers instead.
Engineering Considerations
Use a stack when the feature has ordered layers with clear review boundaries. Schema, domain logic, and API changes can form a useful stack when each layer is testable and leaves the target branch in a valid state.
Do not create a stack for a small change or split code at arbitrary file boundaries. That mistake is common with agent-generated features, where the whole diff arrives at once and gets split after the fact. Reviewers should be able to explain what one layer does without reading all later layers.
Keep stacks shallow. Two or three stable layers are manageable by hand. Deep stacks with frequent changes near the root create repeated conflict resolution and force pushes. Stack tools reduce the bookkeeping, as the section above describes.
Merge order matters. Land layers from the root upward. A GitHub merge queue keeps that order and removes every layer above one that fails. If a project uses squash merge, expect the lower layer's commit identity to change on main and restack the remaining branches.
Scaling and Operations
Assign one owner to maintain the branch chain, even when several developers contribute. That owner coordinates restacks, verifies pull-request bases, and tells reviewers when a diff changed after a force push.
Automate these checks:
- every layer has the expected base branch
- commits in one layer do not appear unexpectedly in another
- CI runs for each incremental diff and for the combined stack
- force pushes use leases
- merged layers are retargeted or removed
Review the combined result as well as each layer. Individually correct diffs can still produce a broken integration when assumptions differ across layers.
Avoid dependencies on branches owned by another team unless both teams agree on rewrite policy. A force push to a lower layer changes every dependent branch's base.
Next Steps
- Merge vs Rebase: understand the rewrite and integration choices behind restacking
- Cherry-pick vs Rebase: choose the correct operation for dependent commits
- Stacked PR Workflow: create and maintain a stack step by step
- Rebasing and Stacks answers: short fixes for common stack rebase problems
- Parallel Development Workflow: separate independent work from dependent layers