26/11/2026 10:00am

What Is a Stacked Pull Request? Split a Big PR into Small Layers with gh stack
#Stacked Pull Request
#gh stack
#GitHub
#Pull Request
#Git
We are often forced to choose between two unsatisfying options. The first is to put all the work into one huge Pull Request (PR) that nobody wants to read. The second is to send small PRs and then wait for the first to merge before starting the next piece.
GitHub has opened a feature that tackles this problem directly, called stacked pull requests. Today Superdev Academy walks through what a stack is, how to build one with real commands, and what limits to know before you start.
The problem stacked PRs set out to solve
Suppose you need to add a membership system to a Go project. The work has three connected pieces: the database table structure, the functions that manage the data, and an API page that calls those functions. The second piece needs things from the first, and the third needs things from the second.
If you combine everything into one PR, the reviewer has to read three topics mixed together. If you split it into three PRs, you have to chain the branches yourself, and every time a lower PR merges you must manually fix the target (base) of the next one. That work is tedious and easy to get wrong.
What is a stacked PR
According to the definition in GitHub's About stacked pull requests documentation, a stack is two or more PRs in the same repository. The bottom PR points at the main branch (trunk), which is usually the default branch, and each PR above it points at the branch of the PR directly below it.
The result is that each layer shows only its own diff. Reviewers see small, focused changes one layer at a time. Foundation work, such as a shared data structure, goes in the lower layer, and the work that depends on it goes in the layer above.
On status, the GitHub Octoverse 2026 report states that stacked pull requests have been available as a preview since July 30, and that more than 264,000 developers had used them by September. A feature still in preview can change, so check the latest documentation before using it on your team's real work.
Build a stack with gh stack
The steps below are adapted from GitHub's Quickstart documentation. We have not run them in a real repository, so please try them in a practice repo first.
What you need
The documentation says you need GitHub CLI (gh) version 2.90.0 or later and Git version 2.20 or later. Sign in with gh auth login and have a repository you can push to. Then install the extension with this command.
gh extension install github/gh-stackCreate the first layer
gh stack init
git add .
git commit -m "add member table"The gh stack init command creates the stack's tracking record and the first branch, and asks you for the name you want.
Add the next layer and send it to GitHub
gh stack add member-service
git add .
git commit -m "add member service"
gh stack push
gh stack submitgh stack add creates a new branch stacked on the current layer, gh stack push pushes all the branches, and gh stack submit creates the PRs and links them as a stack. To see the whole picture, including branches, PR links, status and latest commits, use gh stack view.
There is a shortcut for a step you repeat often: gh stack add -Am "MESSAGE" stages, commits and creates the next branch in a single command.
How to merge when there are several layers
GitHub states that you do not have to merge the whole stack at once, but you do have to merge from the bottom up. If you merge the top PR, all the PRs below it are merged as well. If you merge a PR in the middle, the PRs below it are included too, while the PRs above it stay open and are retargeted to the stack's base branch.
The part that saves the most manual work is rebasing. The documentation says that once the bottom PR is merged, the remaining branches are rebased automatically so the next PR points at the default branch on its own. It supports all three merge methods (merge commit, squash and rebase) and works with merge queue.
Limits to know before you use it
Every branch in a stack must be in the same repository. GitHub states that stacks across forks are not supported.
GitHub Desktop does not yet support stacked pull requests.
Branch protection rules, such as requiring CODEOWNER approval, apply to every PR in the stack, not just the bottom layer, and CI that runs on PRs targeting the default branch runs on every layer too.
If you merge through the API, you must use the asynchronous merge API for stacks.
The first limit matters a lot if you contribute to open source projects, because the workflow of forking a repo and sending a PR back to the original cannot be done as a stack. Stacks suit teams working inside a single repo better.
Can't I just chain branches myself?
Yes, and many teams have done this for a long time. Branching off each other and setting each PR's base to the branch below works just as well. If you only have two layers and they merge quickly, the old way may be enough.
Where a stack really helps is when the layers multiply and reviewers ask for changes, because GitHub takes over the PR linking, retargeting after a merge and rebasing that you used to do by hand. The documentation also says that if you already have PRs chained together, GitHub shows a banner offering to convert them into a stack, so you do not have to start over.
To decide what branch rules your team should set before adopting this, we summarized them in GitHub Workflow 2026.
Summary: start with two layers in a practice repo
A stacked PR is a set of PRs in one repository placed one on top of another. Each layer points at the branch below it, reviewers see one diff per layer, and you merge from the bottom up. The feature is still a preview, it runs through the gh stack command, which requires GitHub CLI 2.90.0 or later, and it does not support stacks across forks or GitHub Desktop.
If you want to try it, open a practice repo and build a stack of just two layers with gh stack init, gh stack add and gh stack submit. See how the PR page shows a separate diff for each layer. Once you have seen it yourself, you can decide whether your team should use it yet.
If you want to get fluent with branches, Pull Requests and code review, take a look at the Git & GitHub Essentials course from Superdev Academy. It runs 2 hours across 42 lessons, is taught in Thai, and comes with course materials and a certificate, with 12 months of access. It covers everyday Git and GitHub fundamentals, not stacked PRs specifically. Browse all courses at learn.superdevacademy.com/courses.
🎯 Follow Dev knowledge at Superdev Academy:
🔵 Facebook: Superdev Academy Thailand
🎬 YouTube: Superdev Academy Channel
📸 Instagram: @superdevacademy
🎬 TikTok: @superdevacademy
FAQ: Frequently Asked Questions about This Article
A collection of questions and answers to help you better understand the content of this article.