Skip to content

Stacked PRs in the GitHub UI

This guide walks through the key UI components and workflows for working with Stacked PRs on GitHub.

When a pull request is part of a stack, a stack map appears in the PR header. This component gives you an at-a-glance view of the entire stack and lets you jump between PRs.

The stack map shows:

  • All PRs in the stack, listed in order from top to bottom
  • Which PR you’re currently viewing (highlighted)
  • Clickable links to navigate directly to any PR in the stack
  • Link to Add to Stack, where you can create a new PR that targets the head of the topmost PR
  • Unstack option to dissolve the association between PRs, turning them back into standard PRs

The stack map in a PR header

You can create Stacked PRs entirely from the GitHub UI.

Create a pull request as you normally would. The first PR in the stack targets main (or whatever you want as your trunk branch). There’s nothing special about this step.

Creating the first PR targeting main

Step 2: Create subsequent PRs and add them to the stack

Section titled “Step 2: Create subsequent PRs and add them to the stack”

When you create the next PR, set its base branch to the first PR’s branch. You’ll see a checkbox or option to Create stack. Select this to link this PR to the previous one, starting a new stack.

Creating a second PR with the stack checkbox

After creating the PR, you’ll see the stack map appear in the header, showing both PRs linked together.

The stack map showing the newly created stack

Repeat this process for each additional PR in the stack — each one targets the branch of the PR before it.

If you already have open PRs whose branches line up (each PR’s base branch is the head branch of the PR below it), GitHub recognizes the chain and shows a recommendation banner offering to turn them into a stack.

Banner recommending that eligible PRs be turned into a stack

Click the banner to open a dialog that previews the stack, listing each PR in order from top to bottom. Review it and confirm to link the PRs together into a stack.

Dialog previewing the stack before it’s created

Once you confirm, the PRs are stacked and the stack map appears in each PR’s header.

You can add a PR to the top of an existing stack either when you create the PR or after it already exists.

If you already have an open PR whose base branch is the head branch of the stack’s topmost PR, GitHub shows a recommendation banner on that PR, giving you an option to add it to the stack. Click it to preview and confirm, and the PR is added to the top of the existing stack.

Recommendation dialog for adding an existing PR to a stack

To create a brand-new PR directly on top of the stack:

  1. Open a PR in the stack, click the stack icon in the header, and click Add.

Adding a new PR to an existing stack

  1. On the following page, the base branch is automatically set to the head of the topmost PR. Select the head branch for your new PR and click Create pull request.

Selecting branch to add to stack

  1. Select the checkbox for Add to existing stack and create your pull request.

Creating a PR to add to an existing stack

The new PR will be added to the top of the stack, which you will see on the PRs page.

Stack of Pull Requests

The merge box for a Stacked PR works differently from a regular PR. It shows not just the current PR’s merge status, but the status of the entire stack.

Before a PR in the stack can be merged, the following conditions must be met:

  • All PRs below it must be approved and have passing checks
  • The stack must be fully rebased with a linear history
  • The current PR itself must meet all branch protection requirements for the stack base

Merge box for a stacked pull request

When the stack is not linear (e.g., after changes were pushed to a lower branch, or after the trunk has moved ahead), a Rebase Stack button appears in the merge box. Clicking it triggers a server-side cascading rebase that:

  1. Rebases the entire stack on top of the latest trunk (e.g., main) HEAD.
  2. Rebases every unmerged branch on top of the latest changes from its base branch, working from the bottom of the stack upward.
  3. Force-pushes each rebased branch to update the remote.

After the rebase completes, all PRs in the stack reflect the updated branches and CI checks are re-triggered.

If you want to reorder or reorganize the PRs in a stack from the UI, you must first dissolve the stack and then re-create it. For CLI users, gh stack modify provides an interactive way to restructure a stack — including reordering, inserting, dropping, and renaming branches — without needing to dissolve it.

To dissolve the stack, use the Unstack option on the stack.

Dissolving an entire stack

Unstacking removes the open, draft, and closed PRs from the stack. Each of those PRs keeps its current base branch but is no longer linked to the others, and the stack map and stack-related merge requirements disappear from them.

Merged and queued PRs stay in the stack. Once a PR has merged — or is queued for merge — as part of a stack, it remains part of that stack and can’t be unstacked. So if every PR in the stack is open, draft, or closed, unstacking removes them all and the stack is dissolved entirely; if any PR has already merged or is queued for merge, the stack persists with those PRs still in it.