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
+11-24Lines changed: 11 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,19 +76,15 @@ Initialize a new stack in the current repository.
76
76
gh stack init [flags] [branches...]
77
77
```
78
78
79
-
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. If a branch name contains slashes (e.g., `feat/api`), prompts if you would like to use a prefix (e.g., `feat/`) for all branches in the stack.
79
+
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.
80
80
81
81
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`.
82
82
83
-
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.
84
-
85
83
Enables `git rerere` automatically so that conflict resolutions are remembered across rebases.
86
84
87
85
| Flag | Description |
88
86
|------|-------------|
89
87
|`-b, --base <branch>`| Trunk branch for the stack (defaults to the repository's default branch) |
90
-
|`-p, --prefix <string>`| Set a branch name prefix for the stack |
91
-
|`-n, --numbered`| Use auto-incrementing numbered branch names (requires `--prefix`) |
# Set a prefix — you'll be prompted for a branch name
109
-
gh stack init -p feat
110
-
# → prompts "Enter a name for the first branch (will be prefixed with feat/)"
111
-
# → type "auth" → creates feat/auth
112
-
113
-
# Use numbered auto-incrementing branch names
114
-
gh stack init -p feat --numbered
115
-
# → creates feat/01 automatically
116
103
```
117
104
118
105
### `gh stack add`
@@ -125,7 +112,7 @@ gh stack add [flags] [branch]
125
112
126
113
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.
127
114
128
-
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`).
115
+
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`).
129
116
130
117
| Flag | Description |
131
118
|------|-------------|
@@ -616,42 +603,42 @@ gh stack sync
616
603
617
604
## Abbreviated workflow
618
605
619
-
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.
606
+
If you want to minimize keystrokes, use the `-Am` flags to fold staging, committing, and branch creation into a single command. When you don't pass a branch name, one is auto-generated from the commit message in date+slug format (e.g., `03-24-auth_middleware`).
620
607
621
608
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.
622
609
623
610
```sh
624
-
# 1. Start a stack with a prefix and numbered branches
625
-
gh stack init -p feat --numbered
626
-
# → creates feat/01 and checks it out
611
+
# 1. Start a stack
612
+
gh stack init auth
613
+
# → creates auth and checks it out
627
614
628
615
# 2. Write code for the first layer
629
616
# ... write code ...
630
617
631
618
# 3. Stage and commit on the current branch
632
619
gh stack add -Am "Auth middleware"
633
-
# → feat/01 has no commits yet, so the commit lands here
620
+
# → auth has no commits yet, so the commit lands here
634
621
# (no new branch is created)
635
622
636
623
# 4. Write code for the next layer
637
624
# ... write code ...
638
625
639
626
# 5. Create the next branch and commit
640
627
gh stack add -Am "API routes"
641
-
# → feat/01 already has commits, so a new branch feat/02 is
642
-
#created, checked out, and the commit lands there
628
+
# → auth already has commits, so a new branch is created from the
629
+
#commit message, checked out, and the commit lands there
643
630
644
631
# 6. Keep going
645
632
# ... write code ...
646
633
647
634
gh stack add -Am "Frontend components"
648
-
# → feat/02 already has commits, creates feat/03 and commits there
635
+
# → creates another branch and commits there
649
636
650
637
# 7. Push everything and create PRs
651
638
gh stack submit
652
639
```
653
640
654
-
Compared to the typical workflow, there's no need to name branches, run `git add`, or run `git commit` separately. Each `gh stack add -Am "..."` does it all.
641
+
Compared to the typical workflow, there's no need to name branches, run `git add`, or run `git commit` separately. Each `gh stack add -Am "..."` does it all. Pass an explicit branch name any time you want to control it: `gh stack add -Am "API routes" api-routes`.
0 commit comments