Skip to content

Commit 1aeb0c0

Browse files
committed
updated link docs
1 parent bf8a3e8 commit 1aeb0c0

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

docs/src/content/docs/faq.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,14 @@ This doesn't create any local tracking and only hits the APIs to create Stacked
255255

256256
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.
257257

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:
259266

260267
```bash
261268
gh stack link 123 124 125 change4 change5

docs/src/content/docs/reference/cli.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ gh stack push --remote upstream
430430
Link PRs into a stack on GitHub without local tracking.
431431

432432
```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> [...]
434434
```
435435

436436
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
439439

440440
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.
441441

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+
442444
| Flag | Description |
443445
|------|-------------|
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 |
445447
| `--open` | Mark new and existing PRs as ready for review |
446448
| `--remote <name>` | Remote to push to (defaults to auto-detected remote) |
447449

@@ -460,6 +462,10 @@ gh stack link https://github.com/owner/repo/pull/10 https://github.com/owner/rep
460462
# Add branches to an existing stack of PRs
461463
gh stack link 42 43 feature-auth feature-ui
462464

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+
463469
# Use a different base branch and mark PRs as ready for review
464470
gh stack link --base develop --open feat-a feat-b feat-c
465471
```

skills/gh-stack/SKILL.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ git config remote.pushDefault origin # if multiple remotes exist (skips remo
6161
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`.
6262
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.
6363
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`).
6565

6666
**Never do any of the following — each triggers an interactive prompt or TUI that will hang:**
6767
-`gh stack view` or `gh stack view --short` — always use `gh stack view --json`
@@ -573,7 +573,7 @@ gh stack submit --auto --open
573573
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.
574574

575575
```
576-
gh stack link [flags] <branch-or-pr> <branch-or-pr> [...]
576+
gh stack link [flags] <stack-number | branch-or-pr> <branch-or-pr> [...]
577577
```
578578

579579
```bash
@@ -588,8 +588,14 @@ gh stack link 10 20 30
588588

589589
# Add branches to an existing stack of PRs
590590
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
591595
```
592596

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+
593599
| Flag | Description |
594600
|------|---------|
595601
| `--base <branch>` | Base branch for the bottom of the stack (default: `main`) |

0 commit comments

Comments
 (0)