Summary
Add optional GitHub Stacks integration so git-gud can register/update stacked PR chains in GitHub when the repository has GitHub Stacks enabled.
Motivation
git-gud already creates GitHub PR stacks in a way that appears structurally compatible with GitHub's new Stacked PRs UI:
- one branch per stack entry
- the first PR targets the base branch
- each subsequent PR targets the previous entry branch
gg sync already updates PR base branches when needed
This means the hard part is already solved. The missing piece is a best-effort integration layer that tells GitHub "these PRs form a stack" so repositories with the feature enabled can benefit from the native stack UI.
Current state
Today git-gud already does all of this:
- creates per-entry branches for each stack layer
- creates GitHub PRs with the correct base chain
- updates existing PR base branches with
gh pr edit --base
- tracks entry-to-PR mappings locally
- preserves stable internal metadata with
GG-ID / GG-Parent
That should be enough for compatibility at the PR graph level.
Proposal
Add an optional GitHub-only integration that runs after gg sync finishes creating/updating PRs.
Config
Introduce a GitHub-specific config option:
{
"defaults": {
"github": {
"stacks_integration": "auto"
}
}
}
Supported values:
off: never attempt GitHub Stacks integration
auto: attempt integration only when support is available
force: always attempt integration and surface failures more explicitly
Default: auto
Sync behavior
At the end of gg sync, when provider = GitHub:
- collect all active/open PR numbers in stack order (bottom → top)
- if there are fewer than 2 active PRs, do nothing
- detect whether GitHub Stacks support is available for the current repo
- if available, create or update the remote GitHub Stack
- if unavailable in
auto, skip silently or with a minimal note
- if integration fails, show a warning but do not fail
gg sync
Implementation shape
Add a small abstraction in gg-core, for example:
github_stacks.rs
- a
GitHubStacksBackend trait or similar wrapper
This should allow us to support two backends:
Preferred backend: gh stack
If the official gh stack extension/command provides a safe way to adopt existing PR chains or register stacks for already-created PRs, prefer using it. This keeps git-gud aligned with GitHub's supported surface.
Fallback backend: direct GitHub Stacks API
If gh stack is not sufficient for adoption, add an experimental API backend that talks directly to the GitHub Stacks preview endpoints.
The backend choice should be hidden behind one integration layer so we can switch strategies later without touching the sync workflow.
Design constraints
- Keep
git-gud's current stack model unchanged
- Do not remove or weaken
GG-ID / GG-Parent
- Do not require GitHub Stacks for normal GitHub usage
- Do not affect GitLab behavior
- Treat the integration as best-effort and non-fatal
Why this is a good fit for git-gud
git-gud already has the exact data needed to build a remote stack:
- ordered stack entries
- entry branch names
- PR numbers for each entry
- open/merged state
So this should be a focused feature rather than a redesign.
Suggested tasks
Summary
Add optional GitHub Stacks integration so
git-gudcan register/update stacked PR chains in GitHub when the repository has GitHub Stacks enabled.Motivation
git-gudalready creates GitHub PR stacks in a way that appears structurally compatible with GitHub's new Stacked PRs UI:gg syncalready updates PR base branches when neededThis means the hard part is already solved. The missing piece is a best-effort integration layer that tells GitHub "these PRs form a stack" so repositories with the feature enabled can benefit from the native stack UI.
Current state
Today
git-gudalready does all of this:gh pr edit --baseGG-ID/GG-ParentThat should be enough for compatibility at the PR graph level.
Proposal
Add an optional GitHub-only integration that runs after
gg syncfinishes creating/updating PRs.Config
Introduce a GitHub-specific config option:
{ "defaults": { "github": { "stacks_integration": "auto" } } }Supported values:
off: never attempt GitHub Stacks integrationauto: attempt integration only when support is availableforce: always attempt integration and surface failures more explicitlyDefault:
autoSync behavior
At the end of
gg sync, when provider = GitHub:auto, skip silently or with a minimal notegg syncImplementation shape
Add a small abstraction in
gg-core, for example:github_stacks.rsGitHubStacksBackendtrait or similar wrapperThis should allow us to support two backends:
Preferred backend:
gh stackIf the official
gh stackextension/command provides a safe way to adopt existing PR chains or register stacks for already-created PRs, prefer using it. This keepsgit-gudaligned with GitHub's supported surface.Fallback backend: direct GitHub Stacks API
If
gh stackis not sufficient for adoption, add an experimental API backend that talks directly to the GitHub Stacks preview endpoints.The backend choice should be hidden behind one integration layer so we can switch strategies later without touching the sync workflow.
Design constraints
git-gud's current stack model unchangedGG-ID/GG-ParentWhy this is a good fit for
git-gudgit-gudalready has the exact data needed to build a remote stack:So this should be a focused feature rather than a redesign.
Suggested tasks
defaults.github.stacks_integrationgg syncoff,auto,forceskills/gg