A guide to stacked PRs

Facilitating code reviews with stacked pull requests

Large pull requests with thousands of modified lines are inherently hard to review: remaining open for days, skimmed over by reviewers instead of checked, and increasingly prone to conflicts as main moves forward in the history tree. GitHub’s stacked pull requests address this by splitting one big change into a chain of small PRs, each built on top of the previous one .

Each PR shows only its own diff, so reviewers can go through them one at a time, bottom to top, while you keep working on your next batch of changes. If there is a way to develop features in a sequential manner, where the next set of changes depends on the previous, this approach becomes ideal.

What a stack looks like

Each branch in the stack starts from the branch directly below it, not from main. The following mermaid diagram shows this explicitly:

gitGraph TB:
    commit id: "main1"
    commit id: "main2"

    branch "stack/a"
    checkout "stack/a"
    commit id: "a1"
    commit id: "a2"

    branch "stack/b"
    checkout "stack/b"
    commit id: "b1"

    branch "stack/c"
    checkout "stack/c"
    commit id: "c1"
    commit id: "c2"

    checkout main
    commit id: "main3"

The bottom branch of the stack (stack/a) directly targets main. Then, the second branch (stack/b) targets stack/a, the third (stack/c) targets stack/b and so on.

Building the stack

The first step is to create each new branch directly from the current one, so the current branch becomes its base branch:

git checkout main
git checkout -b stack/a
git add . && git commit -m "feat: add data model"
git push -u origin stack/a
git checkout -b stack/b      # branches off stack/a
git add . && git commit -m "feat: add API endpoints"
git push -u origin stack/b
git checkout -b stack/c      # branches off stack/b
git add . && git commit -m "feat: add UI"
git push -u origin stack/c

Then, GitHub offers the option to open the PRs as a stack, setting each PR’s base branch to the branch below it. For example, in this stack with three branches:

See GitHub’s guide to stacked pull requests for the details .

Applying changes somewhere lower in the stack

Let’s say that review feedback lands on stack/a. Commit the fix there, then rebase every branch above it onto its new base, from the bottom up:

git checkout stack/a
git add . && git commit -m "fix: address review comments"
git push
git checkout stack/b
git rebase stack/a
git push --force-with-lease
git checkout stack/c
git rebase stack/b
git push --force-with-lease

Rebasing rewrites history, so a force push is needed in this case. Exactly the same idea works for updating from the main branch: rebase the bottom of the stack onto it and then work the way up. The same principle applies for merging.

Or, in one go:

git checkout stack/c
git rebase --update-refs origin/main
git push --force-with-lease origin stack/a stack/b stack/c



If you found this post useful, please cite this as:

Kougioulis, Nikolas (Dec 2026). A guide to stacked PRs. https://nkougioulis.com.

or as a BibTeX entry:

@article{kougioulis2026a-guide-to-stacked-prs,
  title   = {A guide to stacked PRs},
  author  = {Kougioulis, Nikolas},
  year    = {2026},
  month   = {Dec},
  url     = {https://nkougioulis.com/blog/2026/stacked-pr/}
}
Watercolored phoenix drawing