Repository navigation
Description
Describe the bug
After gh stack modify inserts a new branch with no commits of its own below a branch that already has a PR, the modify session stays in pending_submit. modify and modify --abort are both blocked, and the only way out is a successful submit. But submit cannot open a PR for the new branch because it has no commits, so the session can never be cleared. The only escape is deleting .git/gh-stack-modify-state by hand.
Related: #433 (same dead end, triggered by a failed unstack) and #629 (same error message).
Affected command
gh stack modify / gh stack submit
gh-stack version
gh stack version 0.3.0
GitHub CLI version
gh version 2.102.0 (2026-09-30)
Operating system
macOS 26.6.2
Shell
zsh
Steps to reproduce
- Have a stack that has already been submitted, so a remote stack exists:
trunk → A (PR) → B (PR) - Run
gh stack modify, insert a new branchCaboveA(soCpoints atA's tip and has no commits of its own), and apply with Ctrl+S. - Run
gh stack modifyagain → blocked. - Run
gh stack modify --abort→ only prints a hint to runsubmit. - Run
gh stack submit→ cannot create a PR forC, and the session is kept.
Expected behavior
Any of these would avoid the dead end:
modifywarns about, or refuses, inserting a branch with no commits below a branch that has a PR, in a stack that already exists on GitHubsubmitcan finish a pending modify while skipping branches that cannot have a PR yetmodify --abortcan roll back a session inpending_submitusing the saved snapshot
Actual behavior
- Inserting
CchangesB's PR base toC, soaffectsBranchreturns true andfinishApplysaves the session aspending_submit(apply.go#L244, actions.go#L187). modifyrefuses to run while the session is inpending_submit(modify.go#L414-L418), and--abortdoes not restore anything (modify.go#L263-L267).submitcannot create a PR forC(no commits betweenAandC), so not every PR is submitted and the session is kept (submit.go#L302-L309).- Before failing, that
submithas already unstacked the old remote stack and changedB's PR base toC. The remote state has partly changed while the local session is still stuck.
Workaround: back up and delete .git/gh-stack-modify-state, fix the order and base/head entries in .git/gh-stack by hand, move the branch with git branch -f, and change B's PR base back with gh pr edit --base.
Terminal output
$ gh stack modify
✓ Inserted C after A
✓ Stack modified successfully
Inserted: C
Run `gh stack submit` to push your changes and update the stack of PRs on GitHub
$ gh stack modify
✗ a modify was completed but the stack has not been submitted yet
Run `gh stack submit` to push changes and recreate the stack on GitHub
$ gh stack submit
Checking stack state...
? The local stack has been modified. Overwrite the existing stack on GitHub? Yes
✓ Cleared existing stack on GitHub
Pushing to origin...
PR for A is up to date
⚠ failed to create PR for C: creating PR: GraphQL: No commits between A and B (createPullRequest)
✓ Updated base branch for PR (PR number of B) to C
✗ modify is not fully submitted; recovery state was retained
Finish submitting all remaining PRs, then retry `gh stack submit`
Preflight checks
- I searched the existing issues for duplicates.
- I ran
gh extension upgrade stackand reproduced this issue on the latest stable release.
Activity