Skip to content

Commit 03f92b2

Browse files
committed
move up flag references for readability
1 parent 89e8eab commit 03f92b2

1 file changed

Lines changed: 45 additions & 45 deletions

File tree

  • docs/src/content/docs/reference

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

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ Initialize a new stack in the current repository.
2727
gh stack init [flags] [branches...]
2828
```
2929

30+
| Flag | Description |
31+
|------|-------------|
32+
| `-b, --base <branch>` | Trunk branch for the stack (defaults to the repository's default branch) |
33+
3034
Initializes a new stack locally. In interactive mode (no arguments), prompts for a branch name and offers to use the current branch as the first layer.
3135

3236
When explicit branch names are given, existing branches are adopted automatically and any missing branches are created. The trunk defaults to the repository's default branch unless overridden with `--base`.
3337

3438
Enables `git rerere` automatically so that conflict resolutions are remembered across rebases.
3539

36-
| Flag | Description |
37-
|------|-------------|
38-
| `-b, --base <branch>` | Trunk branch for the stack (defaults to the repository's default branch) |
39-
4040
**Examples:**
4141

4242
```sh
@@ -61,10 +61,6 @@ Add a new branch on top of the current stack.
6161
gh stack add [flags] [branch]
6262
```
6363

64-
Creates a new branch at the current HEAD, adds it to the top of the stack, and checks it out. Must be run while on the topmost branch of a stack. If no branch name is given, prompts for one.
65-
66-
You can optionally stage changes and create a commit as part of the `add` flow. When `-m` is provided without an explicit branch name, the branch name is auto-generated in date+slug format (e.g., `03-24-add_login`).
67-
6864
| Flag | Description |
6965
|------|-------------|
7066
| `-A, --all` | Stage all changes (including untracked files); requires `-m` |
@@ -73,6 +69,10 @@ You can optionally stage changes and create a commit as part of the `add` flow.
7369

7470
> **Note:** `-A` and `-u` are mutually exclusive.
7571
72+
Creates a new branch at the current HEAD, adds it to the top of the stack, and checks it out. Must be run while on the topmost branch of a stack. If no branch name is given, prompts for one.
73+
74+
You can optionally stage changes and create a commit as part of the `add` flow. When `-m` is provided without an explicit branch name, the branch name is auto-generated in date+slug format (e.g., `03-24-add_login`).
75+
7676
**Examples:**
7777

7878
```sh
@@ -106,13 +106,13 @@ View the current stack.
106106
gh stack view [flags]
107107
```
108108

109-
Shows all branches in the stack, their ordering, PR links, and the most recent commit with a relative timestamp. Output is piped through a pager (respects `GIT_PAGER`, `PAGER`, or defaults to `less -R`).
110-
111109
| Flag | Description |
112110
|------|-------------|
113111
| `-s, --short` | Compact output (branch names only) |
114112
| `--json` | Output stack data as JSON |
115113

114+
Shows all branches in the stack, their ordering, PR links, and the most recent commit with a relative timestamp. Output is piped through a pager (respects `GIT_PAGER`, `PAGER`, or defaults to `less -R`).
115+
116116
**Examples:**
117117

118118
```sh
@@ -164,13 +164,13 @@ Interactively restructure the current stack.
164164
gh stack modify [flags]
165165
```
166166

167-
Opens an interactive terminal UI for restructuring a stack. All changes are staged in the TUI and applied together when you press `Ctrl+S`. Branches from merged PRs cannot be modified.
168-
169167
| Flag | Description |
170168
|------|-------------|
171169
| `--continue` | Continue after resolving conflicts |
172170
| `--abort` | Abort the modify session and restore the stack to its pre-modify state |
173171

172+
Opens an interactive terminal UI for restructuring a stack. All changes are staged in the TUI and applied together when you press `Ctrl+S`. Branches from merged PRs cannot be modified.
173+
174174
**Preconditions:**
175175

176176
The command checks these conditions before opening the TUI:
@@ -228,6 +228,10 @@ Remove a stack from local tracking and unstack it on GitHub. Also available as `
228228
gh stack unstack [<stack-number>] [flags]
229229
```
230230

231+
| Flag | Description |
232+
|------|-------------|
233+
| `--local` | Only remove the stack locally (keep it on GitHub) |
234+
231235
With no argument, the command targets the active stack — the one that contains the currently checked out branch — unstacking it on GitHub and removing local tracking.
232236

233237
Provide a stack number (the identifier shown in the github.com stack UI) to unstack a specific stack on GitHub. This works from anywhere in the repository, whether or not the stack is checked out locally — the stack is unstacked directly through the GitHub API. When the stack is also available locally, its local tracking is removed as well.
@@ -236,10 +240,6 @@ PRs that are merged, merging, or queued for merge cannot be removed from a stack
236240

237241
This is useful when you need to restructure a stack — remove a branch, insert a branch, reorder branches, rename branches, or make other large changes. After unstacking, use `gh stack init` to re-create the stack with the desired structure — existing branches are adopted automatically.
238242

239-
| Flag | Description |
240-
|------|-------------|
241-
| `--local` | Only remove the stack locally (keep it on GitHub) |
242-
243243
**Examples:**
244244

245245
```sh
@@ -265,6 +265,12 @@ Push all branches and create/update PRs and the stack on GitHub.
265265
gh stack submit [flags]
266266
```
267267

268+
| Flag | Description |
269+
|------|-------------|
270+
| `--auto` | Skip the editor and use auto-generated PR titles |
271+
| `--open` | Create new PRs as ready for review instead of drafts, and mark existing PRs as ready for review |
272+
| `--remote <name>` | Remote to push to (defaults to auto-detected remote) |
273+
268274
Creates a Stacked PR for every branch in the stack, pushing branches to the remote. After creating PRs, `submit` automatically creates a **Stack** on GitHub to link the PRs together. If the stack already exists on GitHub (e.g., from a previous submit), new PRs are added to the existing stack.
269275

270276
If every PR in the stack has already been merged, that stack is complete and can't be extended. In that case `submit` automatically starts a **new** stack rooted at the trunk for your unmerged branches and creates it on GitHub, leaving the merged stack untouched.
@@ -280,12 +286,6 @@ If the branches already have open PRs but no stack exists on GitHub, you will ha
280286

281287
In the editor, new PRs default to **ready for review**; flip any PR to **draft** with the ready ↔ draft toggle. With `--auto`, new PRs are created as **drafts** unless you pass `--open`.
282288

283-
| Flag | Description |
284-
|------|-------------|
285-
| `--auto` | Skip the editor and use auto-generated PR titles |
286-
| `--open` | Create new PRs as ready for review instead of drafts, and mark existing PRs as ready for review |
287-
| `--remote <name>` | Remote to push to (defaults to auto-detected remote) |
288-
289289
**Examples:**
290290

291291
```sh
@@ -302,6 +302,11 @@ Fetch, rebase, push, and sync PR state in a single command.
302302
gh stack sync [flags]
303303
```
304304

305+
| Flag | Description |
306+
|------|-------------|
307+
| `--remote <name>` | Remote to fetch from and push to (defaults to auto-detected remote) |
308+
| `--prune` | Delete local branches for merged PRs |
309+
305310
Performs a synchronization of the entire stack:
306311

307312
1. **Fetch** — fetches the latest changes from `origin`.
@@ -325,11 +330,6 @@ When neither stack is a clean prefix of the other — for example, you added a b
325330

326331
In a non-interactive terminal, a divergence aborts the sync (exit success) without pushing branches or updating PRs; resolve it by unstacking and recreating the stack.
327332

328-
| Flag | Description |
329-
|------|-------------|
330-
| `--remote <name>` | Remote to fetch from and push to (defaults to auto-detected remote) |
331-
| `--prune` | Delete local branches for merged PRs |
332-
333333
**Examples:**
334334

335335
```sh
@@ -347,12 +347,6 @@ Pull from remote and do a cascading rebase across the stack.
347347
gh stack rebase [flags] [branch]
348348
```
349349

350-
Fetches the latest changes from `origin`, then ensures each branch in the stack has the tip of the previous layer in its commit history. Rebases branches in order from trunk upward.
351-
352-
If a branch's PR has been merged, the rebase automatically switches to `--onto` mode to correctly replay commits on top of the merge target.
353-
354-
If a rebase conflict occurs, the operation pauses and prints the conflicted files with line numbers. Resolve the conflicts, stage with `git add`, and continue with `--continue`. To undo the entire rebase, use `--abort` to restore all branches to their pre-rebase state.
355-
356350
| Flag | Description |
357351
|------|-------------|
358352
| `--downstack` | Only rebase branches from trunk to the current branch |
@@ -363,6 +357,12 @@ If a rebase conflict occurs, the operation pauses and prints the conflicted file
363357
| `--remote <name>` | Remote to fetch from (defaults to auto-detected remote) |
364358
| `--committer-date-is-author-date` | Set the committer date to the author date during rebase. Alias: `--preserve-dates` |
365359

360+
Fetches the latest changes from `origin`, then ensures each branch in the stack has the tip of the previous layer in its commit history. Rebases branches in order from trunk upward.
361+
362+
If a branch's PR has been merged, the rebase automatically switches to `--onto` mode to correctly replay commits on top of the merge target.
363+
364+
If a rebase conflict occurs, the operation pauses and prints the conflicted files with line numbers. Resolve the conflicts, stage with `git add`, and continue with `--continue`. To undo the entire rebase, use `--abort` to restore all branches to their pre-rebase state.
365+
366366
| Argument | Description |
367367
|----------|-------------|
368368
| `[branch]` | Target branch (defaults to the current branch) |
@@ -400,12 +400,12 @@ Push all branches in the current stack to the remote.
400400
gh stack push [flags]
401401
```
402402

403-
Pushes every branch to the remote using `--force-with-lease --atomic`. This is a lightweight wrapper around `git push` that knows about all branches in the stack. It does not create or update pull requests — use `gh stack submit` for that.
404-
405403
| Flag | Description |
406404
|------|-------------|
407405
| `--remote <name>` | Remote to push to (defaults to auto-detected remote) |
408406

407+
Pushes every branch to the remote using `--force-with-lease --atomic`. This is a lightweight wrapper around `git push` that knows about all branches in the stack. It does not create or update pull requests — use `gh stack submit` for that.
408+
409409
**Examples:**
410410

411411
```sh
@@ -421,6 +421,12 @@ Link PRs into a stack on GitHub without local tracking.
421421
gh stack link [flags] <stack-number | branch-or-pr> <branch-or-pr> [...]
422422
```
423423

424+
| Flag | Description |
425+
|------|-------------|
426+
| `--base <branch>` | Base branch for the bottom of the stack (defaults to the repository's default branch); ignored when adding to an existing stack |
427+
| `--open` | Mark new and existing PRs as ready for review |
428+
| `--remote <name>` | Remote to push to (defaults to auto-detected remote) |
429+
424430
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.
425431

426432
Arguments are provided in stack order (bottom to top). Branch arguments are automatically pushed to the remote before creating or looking up PRs. For branches that already have open PRs, those PRs are used. For branches without PRs, new PRs are created automatically with the correct base branch chaining. Existing PRs whose base branch doesn't match the expected chain are corrected automatically.
@@ -429,12 +435,6 @@ If the PRs are not yet in a stack, a new stack is created. If some of the PRs ar
429435

430436
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.
431437

432-
| Flag | Description |
433-
|------|-------------|
434-
| `--base <branch>` | Base branch for the bottom of the stack (defaults to the repository's default branch); ignored when adding to an existing stack |
435-
| `--open` | Mark new and existing PRs as ready for review |
436-
| `--remote <name>` | Remote to push to (defaults to auto-detected remote) |
437-
438438
**Examples:**
439439

440440
```sh
@@ -566,14 +566,14 @@ Create a short command alias so you can type less.
566566
gh stack alias [flags] [name]
567567
```
568568

569-
Installs a small wrapper script into `~/.local/bin/` that forwards all arguments to `gh stack`. The default alias name is `gs`, but you can choose any name by passing it as an argument. After setup, you can run `gs push` instead of `gh stack push`.
570-
571-
On Windows, automatic alias creation is not supported — the command prints manual instructions for creating a batch file or PowerShell function.
572-
573569
| Flag | Description |
574570
|------|-------------|
575571
| `--remove` | Remove a previously created alias |
576572

573+
Installs a small wrapper script into `~/.local/bin/` that forwards all arguments to `gh stack`. The default alias name is `gs`, but you can choose any name by passing it as an argument. After setup, you can run `gs push` instead of `gh stack push`.
574+
575+
On Windows, automatic alias creation is not supported — the command prints manual instructions for creating a batch file or PowerShell function.
576+
577577
**Examples:**
578578

579579
```sh

0 commit comments

Comments
 (0)