You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/content/docs/faq.md
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -255,7 +255,14 @@ This doesn't create any local tracking and only hits the APIs to create Stacked
255
255
256
256
If the provided branches already have open PRs, `link` will use them. If not, it creates draft PRs by default with the correct base branch chaining.
257
257
258
-
To add more to the stack, run `link` again, but be sure to include the full list of PRs/branches in the stack:
258
+
To add more to the stack, pass the stack number (shown in the GitHub stack UI) as the first argument, followed by just the new PRs or branches — you no longer need to re-list the PRs already in the stack:
259
+
260
+
```bash
261
+
# 42 is the stack number; change4 and change5 are appended to its top
262
+
gh stack link 42 change4 change5
263
+
```
264
+
265
+
You can also pass the full list of PRs/branches (without a leading stack number) to create a stack or additively update an existing one:
Link PRs into a stack on GitHub without local tracking.
431
431
432
432
```sh
433
-
gh stack link [flags] <branch-or-pr><branch-or-pr> [...]
433
+
gh stack link [flags] <stack-number |branch-or-pr><branch-or-pr> [...]
434
434
```
435
435
436
436
Creates or updates a stack on GitHub from branch names or PR numbers/URLs. This command does not create or modify any `gh-stack` local tracking state. It is designed for users who manage branches with other tools locally (e.g., jj, Sapling, git-town) and want to simply open a stack of PRs.
@@ -439,9 +439,11 @@ Arguments are provided in stack order (bottom to top). Branch arguments are auto
439
439
440
440
If the PRs are not yet in a stack, a new stack is created. If some of the PRs are already in a stack, the existing stack is updated to include the new PRs. Existing PRs are never removed from a stack — the update is additive only.
441
441
442
+
To grow an existing stack without re-listing its PRs, pass a stack number (the number shown in the GitHub stack UI) as the first argument. The remaining arguments are appended to the top of that stack. Arguments already in the stack are skipped, and arguments that belong to a different stack are rejected. Because stack and PR numbers never overlap, a numeric first argument is treated as a stack only when it matches an existing stack — otherwise it is treated as a PR or branch.
443
+
442
444
| Flag | Description |
443
445
|------|-------------|
444
-
|`--base <branch>`| Base branch for the bottom of the stack (default: `main`) |
446
+
|`--base <branch>`| Base branch for the bottom of the stack (default: `main`); ignored when adding to an existing stack|
445
447
|`--open`| Mark new and existing PRs as ready for review |
446
448
|`--remote <name>`| Remote to push to (defaults to auto-detected remote) |
447
449
@@ -460,6 +462,10 @@ gh stack link https://github.com/owner/repo/pull/10 https://github.com/owner/rep
460
462
# Add branches to an existing stack of PRs
461
463
gh stack link 42 43 feature-auth feature-ui
462
464
465
+
# Append to the top of an existing stack by its stack number (no need to
466
+
# re-list the PRs already in stack 7)
467
+
gh stack link 7 48 feature-ui
468
+
463
469
# Use a different base branch and mark PRs as ready for review
464
470
gh stack link --base develop --open feat-a feat-b feat-c
7.**Plan your stack layers by dependency order before writing code.** Foundational changes (models, APIs, shared utilities) go in lower branches; dependent changes (UI, consumers) go in higher branches. Think through the dependency chain before running `gh stack init`.
62
62
8.**Use standard `git add` and `git commit` for staging and committing.** This gives you full control over which changes go into each branch. The `-Am` shortcut is available but should not be the default approach—stacked PRs are most effective when each branch contains a deliberate, logical set of changes.
63
63
9.**Navigate down the stack when you need to change a lower layer.** If you're working on a frontend branch and realize you need API changes, don't hack around it at the current layer. Navigate to the appropriate branch (`gh stack down`, `gh stack checkout`, or `gh stack bottom`), make and commit the changes there, run `gh stack rebase --upstack`, then navigate back up to continue.
64
-
10.**Use `gh stack link` for external tool workflows.** When branches are managed by an external tool (jj, Sapling, etc.), use `gh stack link branch-a branch-b`. `link` does not rely on local tracking state and is intended for API-driven PR and stack management. Always provide at least 2 branch names or PR numbers.
64
+
10.**Use `gh stack link` for external tool workflows.** When branches are managed by an external tool (jj, Sapling, etc.), use `gh stack link branch-a branch-b`. `link` does not rely on local tracking state and is intended for API-driven PR and stack management. Provide at least two branches/PRs to create or update a stack, or a stack number followed by the new branches/PRs to append them to the top of an existing stack (e.g. `gh stack link 7 branch-c`).
65
65
66
66
**Never do any of the following — each triggers an interactive prompt or TUI that will hang:**
67
67
- ❌ `gh stack view` or `gh stack view --short` — always use `gh stack view --json`
@@ -573,7 +573,7 @@ gh stack submit --auto --open
573
573
Link PRs into a stack on GitHub without creating any local tracking state. This is the recommended approach if you are managing stacked branches with other tools (jj, Sapling, git-town) and want to simply create GitHub Stacked PRs via an API.
574
574
575
575
```
576
-
gh stack link [flags] <branch-or-pr> <branch-or-pr> [...]
576
+
gh stack link [flags] <stack-number | branch-or-pr> <branch-or-pr> [...]
577
577
```
578
578
579
579
```bash
@@ -588,8 +588,14 @@ gh stack link 10 20 30
588
588
589
589
# Add branches to an existing stack of PRs
590
590
gh stack link 42 43 feature-auth feature-ui
591
+
592
+
# Append to the top of an existing stack by its stack number
593
+
# (7 is a stack number; only the new PRs/branches are listed)
594
+
gh stack link 7 48 feature-auth
591
595
```
592
596
597
+
When the first argument is a stack number, the remaining arguments are appended to the top of that stack, so you don't have to re-list its current PRs. Arguments already in the stack are skipped; arguments in a different stack are rejected. A numeric first argument is treated as a stack only when it matches an existing stack — otherwise it is a PR or branch.
598
+
593
599
| Flag | Description |
594
600
|------|---------|
595
601
|`--base <branch>`| Base branch for the bottom of the stack (default: `main`) |
0 commit comments