Stacked PRs, Native in GitHub
Arrange pull requests in an ordered stack and merge them all in one click. Each PR represents one focused layer of your change, reviewed independently and landed together.
原始链接: https://github.github.com/gh-stack/
## GitHub 堆叠 PR:简化大型变更 GitHub 堆叠 PR 提供了一种管理大型、复杂变更的新方式,即将它们分解为一系列更小、更集中的拉取请求(PR)——一个“堆栈”。每个 PR 建立在前一个 PR 的基础上,允许独立审查和更轻松的冲突解决。 主要功能包括 GitHub UI 内的可视化“堆栈地图”,方便导航,一键级联变基,以及强大的命令行界面 (`gh stack`) 用于本地工作流管理。还提供与 AI 编码代理的集成。 这种方法解决了审查大型 PR 的挑战,提高了上下文、反馈质量和整体团队速度。GitHub 强制执行分支保护和跨整个堆栈的 CI 运行,确保流畅可靠的合并过程。您可以单独合并层,也可以一次性合并所有层,并在每次合并后自动变基剩余的 PR。
Stacked PRs, Native in GitHub
Arrange pull requests in an ordered stack and merge them all in one click. Each PR represents one focused layer of your change, reviewed independently and landed together.
Simplified Stack Management
Navigate between PRs in your stack from the GitHub UI, check the status of every layer at a glance, and trigger a cascading rebase across the entire stack with one click.
Powerful CLI
The gh stack CLI makes it easy to create stacks, perform cascading rebases, push branches and create PRs, and navigate between layers — all from your terminal.
AI Agent Integration
Run npx skills add github/gh-stack to teach your AI coding agents how to work with stacks. Break up a large diff into a stack or develop with stacks from the start.
Large pull requests are hard to review, slow to merge, and prone to conflicts. Reviewers lose context, feedback quality drops, and the whole team slows down. Stacked PRs solve this by breaking big changes into a chain of small, focused pull requests that build on each other — each one independently reviewable.
A stack is a series of pull requests in the same repository where each PR targets the branch of the PR below it, forming an ordered chain that ultimately lands on your main branch.
GitHub understands stacks end-to-end: the pull request UI shows a stack map so reviewers can navigate between layers, branch protection rules are enforced against the final target branch (not just the direct base), and CI runs for every PR in the stack as if they were targeting the final branch.
The gh stack CLI handles the local workflow: creating branches, managing rebases, pushing to GitHub, and creating PRs with the correct base branches. On GitHub, the PR UI gives reviewers the context they need — a stack map for navigation, focused diffs for each layer, and proper rules enforcement.
When you’re ready to merge, you can merge all or a part of the stack. Each PR can be merged directly or through the merge queue. After a merge, the remaining PRs in the stack are automatically rebased so the lowest unmerged PR targets the base branch.
# Install the CLI extension
gh extension install github/gh-stack
# Alias `gh stack` as `gs` for easier use (optional)
# Start a stack (creates and checks out the first branch)
# Create new layers in the stack (creates and checks out each new branch)
Ready to dive in? Start with the Quick Start guide or read the full overview.