Glean 拾遗
日刊 /2026-08-03 / GitHub 堆叠 PR 公开预览:拆小改动、独立评审、一键合入

GitHub 堆叠 PR 公开预览:拆小改动、独立评审、一键合入

原文 github.blog 收录 2026-08-03 11:22 阅读 5 min
AI 解读

GitHub 正式推出堆叠拉取请求(stacked pull requests)公开预览,将大型改动拆解为有序的小型 PR 层,每层可独立评审与检查,所有层可一键合并。支持通过 gh-stack CLI 扩展、github.com、移动端及 Copilot agent 工作。默认保留现有分支保护与必检检查,合并队列支持将在数周内逐步上线。Vercel、TED、WHOOP 等团队已先行使用。

原文 5 分钟
原文 github.blog ↗
§ 1

header image depicting a GitHub merge box for stacked pull requests

头图:堆叠式拉取请求的 GitHub 合并框

§ 2

Stacked pull requests break large changes into small, reviewable pull requests. They’re an ordered series of pull requests that each represent focused layers of your change. With stacks, you can independently review and check each pull request, then merge everything together in one click. No more opening a single large pull request that takes forever to review, or splitting work across multiple branches you have to keep manually rebasing.

堆叠式拉取请求(Stacked Pull Requests)把大型改动拆成一个个小而可审查的拉取请求。它们是一个有序的拉取请求序列,每个拉取请求都代表你改动中一个聚焦的层级。借助堆栈,你可以独立审查和检查每个拉取请求,然后一键合并所有内容。不用再打开单个巨型拉取请求、花很久等审查,也不用把工作拆到多个分支上手动反复变基。

§ 3

“We’ve been using GitHub stacked PRs for Next.js for the past few months. It has helped us introduce smaller individual changes while shipping larger features, making it easier to review PRs. – Tim Neutkens, NextJS lead, Vercel”

With stacked pull requests, teams can:

  • Keep large changes moving by reviewing short, narrowly scoped pull requests in parallel.
  • Maintain quality across every layer by using focused pull request reviews alongside existing branch protections to protect main.
  • Merge one, some, or all by landing an entire stack altogether or individual layers one at a time.

And because stacked pull requests are built into GitHub, your existing reviews, checks, and merge requirements all work out of the box.

“过去几个月,我们在 Next.js 上使用了 GitHub 堆叠式 PR。它帮助我们在发布大型功能的同时引入更小的独立改动,让 PR 审查更轻松。—— Vercel 的 Next.js 负责人 Tim Neutkens”

使用堆叠式 PR,团队可以:

  • 并行审查短小、范围聚焦的 PR,让大型改动持续推进。
  • 借助聚焦的 PR 审查,配合现有分支保护来保护 main,在每一层都保持质量。
  • 合并其中一个、几个或全部:可以一次合入整个堆栈,也可以逐层合入。

而且,因为堆叠式拉取请求内置于 GitHub,你现有的审查、检查和合并要求全部开箱即用。

§ 4

“The new Github Stacked PRs preview is incredible. Landing 5 stacked PRs directly to a merge queue all at once! A+++! This removes so much friction (and the gh cli tools + agent skill help a ton)” – John Resig, creator, jQuery

“新的 GitHub 堆叠式 PR 预览太出色了。一次把 5 个堆叠 PR 直接合入合并队列!A+++!这消除了太多摩擦(gh CLI 工具和 agent skill 也帮了大忙)”—— jQuery 创造者 John Resig

§ 5

Install the CLI extension and create your first stack in under a minute:

gh extension install github/gh-stack

不到一分钟即可安装 CLI 扩展并创建第一个堆栈:

gh extension install github/gh-stack
§ 6

Work with stacks on github.com, the GitHub CLI, the GitHub mobile app, or with a coding agent such as GitHub Copilot using the gh-stack skill. Start with a branch and pull request for your first change. Then add branches and pull requests on top of it; each pull request targets the layer below it.

你可以在 github.com、GitHub CLI、GitHub 移动应用上使用堆栈,也可以通过 GitHub Copilot 这类编码代理配合 gh-stack skill 使用。先从第一个改动的分支和拉取请求开始,然后在它之上继续添加分支和拉取请求;每个拉取请求都以下一层为目标。

§ 7

Open any pull request in the stack to review only the diff for that specific layer. Use the stack map at the top of the pull request to see how the change you’re reviewing fits into the larger work. You and your teammates can each review different layers in parallel without blocking further work.

“AI has made TED’s developers dramatically more productive, but that created a new bottleneck: PRs were growing large enough that reviewers were struggling. Stacked PRs help to solve that. By breaking large changes into small, dependency-ordered pieces, review happens in smaller logical chunks – not just faster PR reviews, but more accurate ones. Stacked PRs tighten our feedback loop and help get stable code to ted.com faster.” – Andy Merryman, CTO, TED

打开堆栈中的任意一个拉取请求,就可以只审查该特定层的 diff。利用拉取请求顶部的堆栈地图,可以看清当前审查的改动在大局中的位置。你和队友可以并行审查不同层,而不会阻塞后续工作。

“AI 让 TED 的开发者生产力大幅提升,但这也带来了新的瓶颈:PR 变得太大,审查者已经看不动了。堆叠式 PR 正好解决这个问题。把大型改动拆成按依赖排序的小块后,审查会在更小的逻辑块中进行——不仅 PR 审查更快,而且更准确。堆叠式 PR 收紧了我们的反馈循环,帮助更稳定、更快地把代码送到 ted.com。”—— TED CTO Andy Merryman

§ 8

view of the GitHub pull request page displaying details about the pull request stack

GitHub 拉取请求页面中展示的堆叠式拉取请求详情视图

§ 9

Merge the latest ready pull request to land it and every unmerged layer below it in one single operation. To land part of a stack, merge one or more lower layers—the pull requests above it stay open and automatically rebase and retarget. Your existing branch protections and required checks still govern what reaches main.

“A big change used to mean one giant PR nobody wanted to review. Now it’s a stack of small ones reviewers can actually follow, and the whole stack merges in one shot. It stopped feeling like a tool on top of GitHub and started feeling like GitHub.” – Mayank Saini, connectivity engineer, WHOOP

合并最新的就绪拉取请求,即可在一次操作中合入它以及其下方所有未合并的层。如果想只合入堆栈的一部分,可以合并一个或多个低层——上方的拉取请求会保持打开,并自动变基和重新设为目标。你现有的分支保护和必需检查仍然决定哪些内容可以进入 main。

“过去,一个大型改动意味着一个没人愿意审的巨型 PR。现在它是一个由小型 PR 组成的堆栈,审查者真的能跟下来,而且整个堆栈一次合入。它不再像是 GitHub 之上的一件工具,而是开始让人觉得这就是 GitHub。”—— WHOOP 连接工程师 Mayank Saini

§ 10

Stacked pull requests are rolling out in public preview to all repositories over the coming days. Merge queue support for stacked pull requests is rolling out progressively over the coming weeks.

For more information, check out the stacked pull requests documentation, and share your feedback with us in the stacks discussion.

堆叠式拉取请求将在未来几天内向所有仓库公开预览。对堆叠式拉取请求的合并队列支持,会在未来几周内逐步推出。

更多信息请参阅堆叠式拉取请求文档,也欢迎在 stacks 讨论区向我们分享反馈。

打开原文 ↗