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: README.md
+15-6Lines changed: 15 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,7 +71,9 @@ Initialize a new stack in the current repository.
71
71
gh stack init [branches...] [flags]
72
72
```
73
73
74
-
Creates an entry in `.git/gh-stack` to track stack state. In interactive mode (no arguments), prompts you to name branches and offers to use the current branch as the first layer. In interactive mode, you'll also be prompted to set an optional branch prefix for auto-naming (unless adopting existing branches). When explicit branch names are given, creates any that don't already exist (branching from the trunk). The trunk defaults to the repository's default branch unless overridden with `--base`.
74
+
Creates an entry in `.git/gh-stack` to track stack state. In interactive mode (no arguments), prompts you to name branches and offers to use the current branch as the first layer. In interactive mode, you'll also be prompted to set an optional branch prefix (unless adopting existing branches). When a prefix is set, branch names you enter are automatically prefixed. When explicit branch names are given, creates any that don't already exist (branching from the trunk). The trunk defaults to the repository's default branch unless overridden with `--base`.
75
+
76
+
Use `--numbered` with `--prefix` to enable auto-incrementing numbered branch names (`prefix/01`, `prefix/02`, …). Without `--numbered`, you'll always be prompted to provide a meaningful branch name.
75
77
76
78
Enables `git rerere` automatically so that conflict resolutions are remembered across rebases.
77
79
@@ -80,6 +82,7 @@ Enables `git rerere` automatically so that conflict resolutions are remembered a
80
82
|`-b, --base <branch>`| Trunk branch for the stack (defaults to the repository's default branch) |
81
83
|`-a, --adopt`| Adopt existing branches into a stack instead of creating new ones |
82
84
|`-p, --prefix <string>`| Set a branch name prefix for the stack |
85
+
|`-n, --numbered`| Use auto-incrementing numbered branch names (requires `--prefix`) |
# Set a prefix — you'll be prompted for a branch name
100
103
gh stack init -p feat
104
+
# → prompts "Enter a name for the first branch (will be prefixed with feat/)"
105
+
# → type "auth" → creates feat/auth
106
+
107
+
# Use numbered auto-incrementing branch names
108
+
gh stack init -p feat --numbered
109
+
# → creates feat/01 automatically
101
110
```
102
111
103
112
### `gh stack add`
@@ -110,7 +119,7 @@ gh stack add [branch] [flags]
110
119
111
120
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.
112
121
113
-
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. Auto-generated names use either numbered format (`prefix/01`, `prefix/02`) or date+slug format depending on prefix configuration and existing branch naming patterns.
122
+
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. If the stack was created with `--numbered`, auto-generated names use numbered format (`prefix/01`, `prefix/02`); otherwise, date+slug format is used (e.g., `prefix/2025-03-24-add-login`).
114
123
115
124
| Flag | Description |
116
125
|------|-------------|
@@ -409,13 +418,13 @@ gh stack sync
409
418
410
419
## Abbreviated workflow
411
420
412
-
If you want to minimize keystrokes, use a branch prefix and the `-Am` flags to fold staging, committing, and branch creation into a single command. Branch names are auto-generated from your commit messages.
421
+
If you want to minimize keystrokes, use a branch prefix with `--numbered`and the `-Am` flags to fold staging, committing, and branch creation into a single command. Branch names are auto-generated as `prefix/01`, `prefix/02`, etc.
413
422
414
423
When a branch has no commits yet (e.g., right after `init`), `add -Am` stages and commits directly on that branch instead of creating a new one. Once a branch has commits, `add -Am` creates a new branch, checks it out, and commits there.
415
424
416
425
```sh
417
-
# 1. Start a stack with a prefix
418
-
gh stack init -p feat
426
+
# 1. Start a stack with a prefix and numbered branches
0 commit comments