No non-interactive way to select a stack when the branch belongs to several (e.g. the trunk)
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 64/100
Research direction
Start at the gh stack view entry point and trace how it handles multiple stacks, interactive selection, and the discarded positional argument; compare this with the existing gh stack checkout <n> selection behavior. Done means gh stack view --stack <number> can select a stack from a shared branch without changing the checked-out branch, including the reproduced main scenario.
Written by the indexing model from the issue text.
Description
Summary
When the current branch belongs to more than one stack — most commonly the trunk, which is the base of every stack in the repo — gh stack view fails and offers no non-interactive way out:
$ gh stack view --short
✗ branch "main" belongs to multiple stacks; use an interactive terminal to select one
There is no --stack flag. Combined with gh stack view silently discarding positional arguments (#414), there is currently no way at all to view a specific stack non-interactively.
Why this matters
Two stacks off a shared trunk is the normal state for anyone working on more than one change at a time, not an edge case — and main is in that position permanently, so any script or agent that starts from the default branch hits this immediately.
"Use an interactive terminal" is not available in CI, in a shell script, or to an automated agent. The only workaround is to gh stack checkout <n> first purely to move onto a branch in the desired stack, which mutates the working tree just to perform a read.
Reproduction
# create two stacks that both base off main
git switch main
gh stack view --short # -> "belongs to multiple stacks; use an interactive terminal"
Public repo with two stacks off a shared main: https://github.com/xn/gh-stack-repro
Expected
A --stack <number> flag on view (and anywhere else this ambiguity can arise), so the stack can be named explicitly without changing the checked-out branch.
Environment
gh2.97.0gh-stackv0.1.0- git 2.50.1
- macOS 26.4.1, darwin/arm64
- Dominant language
- Go
- Stars
- 1.5k
- Forks
- 73
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from github/gh-stack
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
feature request topic: cli - general
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
feature request topic: auto-merge
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug topic: docs
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Similar issues
-
textual definition
Difficulty 1/5 Under an hour Newbie friendliness 90/100
geneontology/go-ontology#32653 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
-
needs design
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Priority/High ready-for-agent Severity/Major Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100