GitHub: a pull request in a stack does not merge
A stack is a series of pull requests in the same repository where each pull request targets the branch of the pull request below it, forming a chain that lands on a single branch, the stack's base (its trunk). Before a pull request in a stack can merge, it must meet every branch protection requirement for the stack's base, all pull requests below it must meet those requirements too, and the stack must have a fully linear history between its branches (GitHub's stacked pull requests, checked October 26, 2026).
main ← PR #1 ← PR #2 ← PR #3 merging PR #3: #1 and #2 also need their reviews and checks, and land with it
What the merge needs
- The rules of the stack's base: required reviews, required status checks, code owners and code scanning workflows are evaluated as if each pull request targets the stack's base, not the branch directly below it. A mid-stack pull request is held to the same standard as the bottom one, and workflows run for every pull request in the stack (see checks on every pull request in a stack).
- The pull requests below it: merging PR #3 in the stack above requires PR #1 and PR #2 to also pass checks, have required reviews and satisfy all branch protection rules. A mid-stack pull request cannot merge in isolation: the pull requests below it always merge with it.
- A linear history: a stack loses it when changes are pushed to a lower branch, or when the trunk moves ahead. The merge box then shows Rebase stack, and the stack must be rebased before it can merge.
- One repository: all branches of a stack must be in the same repository; stacks across forks are not supported.
What does not work for a stack
- Auto-merge: auto-merge is not supported for stacked pull requests (GitHub's merging stacked pull requests).
- The REST merge endpoint: "Merge a pull request" (
PUT /repos/OWNER/REPO/pulls/NUMBER/merge) does not support stacked pull requests or merging with a merge queue. "Merge a pull request asynchronously" is the required API for merging stacked pull requests, and for a pull request in a stack it includes all open pull requests below it (GitHub's REST API endpoints for pull requests). - Bypassing the rules: only the bottom pull request can be merged with bypass rules; the whole stack cannot.
What to do
- Rebase the stack: click Rebase stack in the merge box for a cascading rebase on GitHub's side, or run
gh stack rebaseand thengh stack push. Rebasing generates signed commits, and keeps approvals when a pull request's diff does not change, even with the rule that dismisses stale approvals enabled. - Merge from the bottom up: go to the lowest unmerged pull request, or to a higher one to merge a contiguous group up to it. It lands together with all unmerged pull requests below it as a single operation, and the next unmerged pull request is then rebased to target the stack's base directly.
- Through the REST API:
PUT /repos/OWNER/REPO/pulls/NUMBER/merge-async, withmerge_actiondirect_mergeormerge_queue, answers 202 with a UUID;GET …/merge-async/UUIDthen gives the result:pending,merged,enqueued(added to a merge queue, not merged yet) orfailed, with a message. At the request only basic checks run (a closed pull request or a draft gets 400); branch protection rules and repository rules are not run at that stage. A result is kept for 24 hours after its last update. - With a merge queue: all pull requests of the stack are added to the queue in order, and when one is removed from the queue, all pull requests above it are removed too. To keep a stack together, a merge group may exceed its maximum size by up to 50 percent.
- Find the rules: anyone with read access to a repository can view its active rulesets (GitHub's about rulesets); look at the ones on the stack's base, not on the branch the pull request targets directly.
GitHub pull requests in IntelliJ IDEA
Pull Request Inbox for GitHub, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, shows a pull request's reviews, checks and conversations next to the diff, and merges it with the methods the target branch allows. For a pull request in a stack, Merge goes through GitHub's asynchronous merge and lands it together with the open pull requests below it, onto the stack's base, or adds them to that branch's merge queue; its merge checks say that it is part of a stack and read the rules of the stack's base, and auto-merge is not offered for it. The review inbox, diffs and conversations are free; approving, commenting, resolving and merging are Pro (US$1.50 a month, with a 30-day trial).
GitHub is a trademark of GitHub, Inc.; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by GitHub, Inc. or JetBrains.
More: GitHub merge refused (405, 409) · GitHub review refused (422) · GitHub search 422 "Validation Failed" · "Resource not accessible by personal access token" · 401 "Bad credentials" · "Resource protected by organization SAML enforcement" · "API rate limit exceeded" · GitHub diff 406 "too_large", 3,000 files · GitHub line comment 422 "must be part of the diff" · GitHub branch update refused (422) · GitHub pull request not created (422, 403) · GitHub auto-merge refused · GitHub draft, ready for review or close refused · GitHub conversation not resolved · GitHub checks not shown (check runs 403) · GitHub file contents not read · GitHub compare refused (404, 422) · GitHub comment or reply refused (403 locked, archived) · GitHub merge method not allowed (405) · GitHub branch not found (404, 301) · GitHub Enterprise Server not reached · GitHub review request not shown · GitHub pull request list incomplete · GitHub 404 Not Found, renamed repositories (301, 307) · GitHub line comment outdated or not on the diff · GitHub pull requests not updating, notifications late · GitHub suggested change cannot be applied · GitHub required check stuck at "Expected" · GitHub code owner review required · GitHub merge blocked by unresolved conversations · GitHub merge blocked by unsigned commits · GitHub branch that merges through a merge queue · GitHub merge waiting for an approval of the most recent push · GitHub merge waiting for code scanning results · GitHub merge waiting for code quality results · GitHub merge blocked by a code coverage threshold · GitHub merge blocked by license compliance results · GitHub branch locked or its updates restricted · GitHub branch not deleted after merging · GitHub merge waiting for a team's approval (Required reviewers) · GitHub merge blocked by secret scanning alerts · GitHub push blocked by push rules · GitHub merge blocked by commit metadata rules · GitHub force push blocked · GitHub issue not closed by a merged pull request · GitHub pull request not checked out locally · GitHub pull request has merge conflicts · GitHub changes requested and dismissing a review · GitHub co-author not credited for a commit · GitHub dependency review check failed · GitHub Dependabot not rebasing its pull request · GitHub fork not syncing with upstream · GitHub pull request base branch not changing · GitHub pull request not reverting · GitHub pull request template not showing · GitHub pull request labels or assignees not added · GitHub pull request not closing or reopening · GitHub push blocked by push protection · GitHub pull request comment hidden · GitHub pull request blocked until deployments succeed · GitHub team review request replaced by members · GitHub pull request file no longer marked Viewed · GitHub pull request marked merged without being merged · GitHub Copilot review does not count as an approval · GitHub checks not running on a pull request a workflow created · GitHub Update branch button not shown on a pull request · GitHub checks failing on a Dependabot pull request · GitHub checks failing on a pull request from a fork · GitHub checks skipped by [skip ci] in a commit message · GitHub checks gone after the retention period · GitHub code review limits in a public repository · GitHub pull requests turned off or limited in a repository · GitHub checks run on every pull request in a stack · GitHub pull request showing commits already squash merged · GitHub pull request not showing a file diff · GitHub push to a pull request branch from a fork refused · GitHub check cancelled on a pull request · GitHub Rebase and merge not available · GitHub merge commit message not what you expected · GitHub pull request shows every line changed · GitHub API request timed out · GitHub pull request image or document diff not shown · GitHub review request refused (422) · GitHub pull request from Copilot: checks not running, approval not counted · GitHub push refused: GH006 and GH013 on a protected branch · GitHub "At least 1 approving review is required", approvals that do not count · GitHub pull request plugins for IntelliJ IDEA, compared · 日本語