Loading...
Loading...
Use for stacked PRs with the gh-stack extension: creating, viewing, editing, pushing, submitting, syncing, rebasing, merging, or checking out a stack, or splitting multi-part work into reviewable layers. Also use whenever a stack is checked out or the user mentions stacks, branch layers, or dependent PRs.
npx skill4agent add jssblck/agents gh-stackgh stackgh stack(main) <- auth <- api <- frontendauthmainfrontendupdownreferences/stack-design.mdgh extension install github/gh-stack
git config rerere.enabled true # remember conflict resolutions
git config remote.pushDefault origin # required if the repo has more than one remotegh stackpushsubmitsyncrebaselink--remote <name>remote.pushDefaultcheckouttrunk--remote| Always run | Never run bare | Why |
|---|---|---|
| | opens a TUI under a PTY |
| | prompts for a title per new PR |
| | |
| | prompts for branch names |
| | prompts for a name, and fails even when piped |
| | opens a selection menu |
| | |
| (none) | | TUI-only, no non-interactive path |
view --short--jsoncheckout <pr>gh stack unstack --localgh stack view --jsongit log --all -- <path>gh stack down # or: gh stack checkout api
git add ... && git commit -m "Add get-user endpoint"
gh stack rebase --upstack # replay every branch above onto the change
gh stack top # return to where you were
gh stack pushgh stack init auth # create the stack and check out its branch
git add ... && git commit -m "Add auth middleware"
gh stack add api # next layer, branched from the current one
git add ... && git commit -m "Add API routes"
gh stack submit --auto # push every branch and open draft PRs
gh stack view --json # confirm--opensubmitgh stack add refactor/foorefactor/foogh stack sync # fetch, reconcile with GitHub, rebase, push, refresh PR state
gh stack sync --prune # also delete local branches for merged PRs--prunesyncSync abortedreferences/troubleshooting.mdgh stack merge 42 --yes # PR #42 plus every unmerged PR below it
gh stack merge 7 --yes # every unmerged PR in stack #7
gh stack merge 42 --yes --squash # or --merge, --rebase, --merge-method <method>gh stack view --jsontrunk string
currentBranch string
branches[] name, head, base, isCurrent, isMerged, isQueued, needsRebase
branches[].pr number, url, state ("OPEN" | "MERGED" | "QUEUED"); absent when no PR existsbaseneedsRebase| Code | Meaning | Recovery |
|---|---|---|
| 0 | Success | (none) |
| 1 | Generic error | Read stderr |
| 2 | Not in a stack | |
| 3 | Rebase conflict | Follow the Exit 3 recovery below |
| 4 | GitHub API failure | Check |
| 5 | Invalid arguments | Fix the invocation; see |
| 6 | Disambiguation required | Branch is in several stacks; check out a non-shared branch |
| 7 | Rebase already in progress | |
| 8 | Stack file locked | Another |
| 9 | Stacked PRs unavailable | Not enabled on the repository; tell the user |
| 10 | Modify recovery required | |
gh stack rebasegit addgh stack rebase --continuegh stack rebase --abortgh stack syncgh stack rebasegh stack modifyunstackinitgh pr editcheckout <branch-name>gh stack <command> --helpgh stack help <command>references/stack-design.mdreferences/commands.mdreferences/troubleshooting.md