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/reference/cli.md
+45-45Lines changed: 45 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,16 +27,16 @@ Initialize a new stack in the current repository.
27
27
gh stack init [flags] [branches...]
28
28
```
29
29
30
+
| Flag | Description |
31
+
|------|-------------|
32
+
|`-b, --base <branch>`| Trunk branch for the stack (defaults to the repository's default branch) |
33
+
30
34
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.
31
35
32
36
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`.
33
37
34
38
Enables `git rerere` automatically so that conflict resolutions are remembered across rebases.
35
39
36
-
| Flag | Description |
37
-
|------|-------------|
38
-
|`-b, --base <branch>`| Trunk branch for the stack (defaults to the repository's default branch) |
39
-
40
40
**Examples:**
41
41
42
42
```sh
@@ -61,10 +61,6 @@ Add a new branch on top of the current stack.
61
61
gh stack add [flags] [branch]
62
62
```
63
63
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
-
68
64
| Flag | Description |
69
65
|------|-------------|
70
66
|`-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.
73
69
74
70
> **Note:**`-A` and `-u` are mutually exclusive.
75
71
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
+
76
76
**Examples:**
77
77
78
78
```sh
@@ -106,13 +106,13 @@ View the current stack.
106
106
gh stack view [flags]
107
107
```
108
108
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`).
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
+
116
116
**Examples:**
117
117
118
118
```sh
@@ -164,13 +164,13 @@ Interactively restructure the current stack.
164
164
gh stack modify [flags]
165
165
```
166
166
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
-
169
167
| Flag | Description |
170
168
|------|-------------|
171
169
|`--continue`| Continue after resolving conflicts |
172
170
|`--abort`| Abort the modify session and restore the stack to its pre-modify state |
173
171
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
+
174
174
**Preconditions:**
175
175
176
176
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 `
228
228
gh stack unstack [<stack-number>] [flags]
229
229
```
230
230
231
+
| Flag | Description |
232
+
|------|-------------|
233
+
|`--local`| Only remove the stack locally (keep it on GitHub) |
234
+
231
235
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.
232
236
233
237
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
236
240
237
241
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.
238
242
239
-
| Flag | Description |
240
-
|------|-------------|
241
-
|`--local`| Only remove the stack locally (keep it on GitHub) |
242
-
243
243
**Examples:**
244
244
245
245
```sh
@@ -265,6 +265,12 @@ Push all branches and create/update PRs and the stack on GitHub.
265
265
gh stack submit [flags]
266
266
```
267
267
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
+
268
274
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.
269
275
270
276
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
280
286
281
287
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`.
282
288
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
-
289
289
**Examples:**
290
290
291
291
```sh
@@ -302,6 +302,11 @@ Fetch, rebase, push, and sync PR state in a single command.
302
302
gh stack sync [flags]
303
303
```
304
304
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
+
305
310
Performs a synchronization of the entire stack:
306
311
307
312
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
325
330
326
331
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.
327
332
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
-
333
333
**Examples:**
334
334
335
335
```sh
@@ -347,12 +347,6 @@ Pull from remote and do a cascading rebase across the stack.
347
347
gh stack rebase [flags] [branch]
348
348
```
349
349
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
-
356
350
| Flag | Description |
357
351
|------|-------------|
358
352
|`--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
363
357
|`--remote <name>`| Remote to fetch from (defaults to auto-detected remote) |
364
358
|`--committer-date-is-author-date`| Set the committer date to the author date during rebase. Alias: `--preserve-dates`|
365
359
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
+
366
366
| Argument | Description |
367
367
|----------|-------------|
368
368
|`[branch]`| Target branch (defaults to the current branch) |
@@ -400,12 +400,12 @@ Push all branches in the current stack to the remote.
400
400
gh stack push [flags]
401
401
```
402
402
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
-
405
403
| Flag | Description |
406
404
|------|-------------|
407
405
|`--remote <name>`| Remote to push to (defaults to auto-detected remote) |
408
406
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
+
409
409
**Examples:**
410
410
411
411
```sh
@@ -421,6 +421,12 @@ Link PRs into a stack on GitHub without local tracking.
421
421
gh stack link [flags] <stack-number | branch-or-pr><branch-or-pr> [...]
422
422
```
423
423
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
+
424
430
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.
425
431
426
432
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
429
435
430
436
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.
431
437
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
-
438
438
**Examples:**
439
439
440
440
```sh
@@ -566,14 +566,14 @@ Create a short command alias so you can type less.
566
566
gh stack alias [flags] [name]
567
567
```
568
568
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
-
573
569
| Flag | Description |
574
570
|------|-------------|
575
571
|`--remove`| Remove a previously created alias |
576
572
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.
0 commit comments