HomeGitHub Copilotgh stack で PR を積んでみた ── リベースは自動、ただし直列しか組めない

gh stack で PR を積んでみた ── リベースは自動、ただし直列しか組めないA hands-on trial of GitHub's stacked PR feature (public preview July 2026) with…

AI2 点サマリSummary highlight
  • 2026年7月30日にパブリックプレビューとなったGitHubのスタックPR機能を3層構成で検証。
  • squashマージ後も上位PRのベースが自動で切り替わり、`gh stack sync`で線形履歴が復元されることを確認した。

A hands-on trial of GitHub's stacked PR feature (public preview July 2026) with three layers confirmed that squash-merging a base PR automatically retargets upper PRs, and `gh stack sync` restores linear history on top of the squash commit.

要約と収集メタデータをもとに生成した AI 解説本文です。元記事全文の転載・翻訳ではありません。This AI explainer is generated from the summaries and collected metadata, not from a reproduction or translation of the full source article.

GitHubが2026年7月30日にパブリックプレビューとして公開した「スタックPR」機能を、個人のprivateリポジトリで3層構成に組んで検証したレポートが公開された。大きな変更を小さなプルリクエストに分割してレビューしやすくする、いわゆるスタック運用を公式ツールで扱える点が注目される。

スタックPRとは、複数のプルリクエストを依存関係に沿って積み重ねる開発手法を指す。1本の巨大なPRを避け、下層のブランチの上に上層のブランチを重ねることで、レビュー単位を小さく保てる利点がある。一方で、下層がマージされたあとに上層のベースをどう追従させるかが長年の課題で、これまではGraphiteやMetaのSapling、ghstack、sprといったサードパーティ製ツールが独自にこの体験を提供してきた。

検証で最も焦点となったのは、squashマージによって履歴が崩れないかという点だった。筆者によれば結果は崩れなかったという。下層のPRをsquashマージした瞬間、サーバー側で上層PRのベースが自動的にmainへ切り替わる。squashで一度は失われた線形性は、gh stack sync コマンドが「adjusted for merged PR」としてスカッシュコミットの上へ載せ替えることで復元されると報告している。

squashマージ後も上位PRのベースが自動で切り替わり、`gh stack sync`で線形履歴が復元されることを確認した。
🧠 GitHub Copilot · 本記事のポイント

一方で、機能の射程は現時点で明確に狭いとも指摘する。対象は同一リポジトリ内に限定され、クロスフォークには対応していないとされる。また積める構成は直列のみで、複数の枝を並行させるような分岐したスタックは組めないという。

リベース処理が自動化される点は、手作業でのベース付け替えに伴う煩雑さを軽減する可能性がある。ただし本機能はパブリックプレビュー段階であり、仕様や挙動は今後変わる余地がある。既存のサードパーティ製ワークフローと比べてどこまで実運用に耐えるかは、対応範囲の拡大とあわせて見極めが必要と見られる。

GitHub has begun a public preview of a native stacked pull request workflow, made available on 30 July 2026, and a recent hands-on trial suggests it handles one of the format's most persistent pain points—squash merges—more gracefully than many longtime practitioners might expect. Stacked PRs let developers split a large change into a chain of smaller, dependent pull requests that build on one another, making each piece easier to review while keeping the overall work moving. Whether GitHub's implementation preserves clean history through merges has been the central open question, and the new tooling appears to address it directly.

The trial was conducted on a personal private repository with a three-layer stack, and the reviewer's primary concern was whether squash-merging the bottom PR would corrupt the history of the layers above it. In practice, it did not. The moment the lowest PR was squash-merged, GitHub automatically retargeted the base of the next PR in the stack to main on the server side, so the remaining pull requests did not point at a now-merged branch. This automatic retargeting removes a manual step that has historically forced developers to babysit each merge.

Squash merges are notoriously awkward for stacked workflows because they collapse a branch's commits into a single new commit, discarding the original commit objects that upper branches were built on top of. That normally breaks the linear relationship between layers. Here, the linearity lost to the squash is restored by running gh stack sync, which the reviewer observed reporting "adjusted for merged PR" as it rebased the remaining work onto the new squash commit. The result is that the stack continues to sit cleanly on top of main rather than diverging or duplicating commits.

The scope of the feature, however, is clearly narrow. It is limited to a single repository, and cross-fork stacks are not supported, which rules out the common open-source contribution pattern where changes flow from a personal fork into an upstream project. Just as importantly, the tooling only builds serial, linear stacks. Developers cannot assemble a branching or tree-shaped arrangement where multiple PRs share a common base and diverge—each layer must sit directly on the one below it. For teams whose work naturally fans out into parallel tracks, that constraint is likely to be a meaningful limitation during the preview.

Context helps explain why this matters. Stacked pull requests are not a new idea, and several third-party tools have grown up to fill the gap that GitHub's default workflow left open. Graphite, git-town, Meta's ghstack, the Sapling source-control system, and the spr command-line tool all offer variations on stacking, each with its own conventions for tracking dependencies and re-syncing after merges. The recurring difficulty across all of them is exactly the scenario tested here: keeping the chain intact once a lower PR lands, especially under squash merges. By building retargeting and sync into the official GitHub CLI, GitHub is bringing a first-party option to a workflow that until now required external tooling or careful manual rebasing.

The gh stack commands extend the GitHub CLI, the official command-line client for interacting with pull requests, issues, and other repository operations. Positioning the feature there, rather than solely in the web interface, signals that GitHub is targeting developers who already manage branches and reviews from the terminal. Because this is a public preview rather than a general release, the behavior, command surface, and supported scenarios could still change before any stable version, and the current same-repository limitation may or may not be relaxed over time.

For now, the practical takeaway from the trial is measured but positive: automatic base retargeting and gh stack sync together preserve a linear history through squash merges in a simple three-layer stack, which is the reassurance many stacked-PR skeptics have been waiting for. The absence of cross-fork support and branching stacks means the feature is best suited, at least during the preview, to individuals and teams working within a single repository on straightforward, linear chains of changes.

  • 出典SourceZenn GitHub CopilotコミュニティCommunity
  • 直近30件の平均重要度Avg importance, last 301=Info · 2=Medium · 3=High
  • 配信形式FormatブログBlog
  • 重要度Importance重要度 MediumMedium priority(GitHub Copilot 191件中、同等以上 154件)(154 of 191 GitHub Copilot entries are equal or higher)
  • 情報の寿命Half-life📘 中期 (チュートリアル)Medium-term (tutorial)
  • 原文言語Source languageJA
  • 収集日時Collected2026/08/15 07:10

本ページの本文と要約は AI による自動生成です。日本語版と英語版は言語ごとに独立して生成されるため、表現や詳しさが異なる場合があります。正確性は元記事 (zenn.dev) をご確認ください。The body and summaries are AI-generated independently for each language, so wording and detail may differ. Verify accuracy at the original source (zenn.dev).

🧠GitHub Copilot の他の記事More from GitHub Copilotもっと見る →View more →