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
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -245,7 +245,7 @@ Interactively restructure the current stack.
245
245
gh stack modify [flags]
246
246
```
247
247
248
-
Opens a terminal UI for restructuring a stack. You can rename, drop, reorder, and fold branches into adjacent ones. All the changes are staged during the preview and applied at once on save.
248
+
Opens a terminal UI for restructuring a stack. You can drop, fold, insert, rename, and reorder branches. All the changes are staged during the preview and applied at once on save.
249
249
250
250
If the stack of PRs has been created on GitHub, run `gh stack submit` afterwards to push the changes and recreate the stack.
251
251
@@ -259,6 +259,7 @@ If the stack of PRs has been created on GitHub, run `gh stack submit` afterwards
259
259
-**Drop** (`x`): Remove a branch and its commits from the stack. Local branch and associated PR are preserved.
260
260
-**Fold down** (`d`): Absorb a branch's commits into the branch below (toward trunk). Folded branch removed from stack.
261
261
-**Fold up** (`u`): Absorb a branch's commits into the branch above (away from trunk). Folded branch removed from stack.
262
+
-**Insert** (`i`/`I`): Insert a new empty branch into the stack. `i` inserts below the cursor; `I` inserts above.
262
263
-**Reorder** (`Shift+↑`/`Shift+↓`): Move a branch up (away from trunk) or down (toward trunk) in the stack.
263
264
-**Rename** (`r`): Rename a branch locally and in the stack metadata.
264
265
-**Undo** (`z`): Undo the last staged action.
@@ -272,7 +273,8 @@ If the stack of PRs has been created on GitHub, run `gh stack submit` afterwards
Copy file name to clipboardExpand all lines: docs/src/content/docs/faq.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,15 +33,15 @@ You can also add PRs to an existing stack from the GitHub UI. See [Adding to an
33
33
34
34
### How can I modify my stack?
35
35
36
-
Use `gh stack modify` to restructure a stack. It opens an interactive terminal UI where you can reorder, drop, fold (combine), and rename branches — then applies all changes at once. See the [Restructuring Stacks](/gh-stack/guides/modify/) guide for a full walkthrough.
36
+
Use `gh stack modify` to restructure a stack. It opens an interactive terminal UI where you can reorder, drop, fold (combine), insert, and rename branches — then applies all changes at once. See the [Restructuring Stacks](/gh-stack/guides/modify/) guide for a full walkthrough.
37
37
38
38
Alternatively, you can manually tear down and re-create the stack with `gh stack unstack` and `gh stack init`:
39
39
40
40
```sh
41
41
# 1. Remove the stack
42
42
gh stack unstack
43
43
44
-
# 2. Make structural changes (reorder, rename, delete branches)
44
+
# 2. Make structural changes (reorder, rename, insert, delete branches)
Copy file name to clipboardExpand all lines: docs/src/content/docs/guides/modify.md
+9-5Lines changed: 9 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Restructuring Stacks
3
3
description: How to use `gh stack modify` to restructure a stack.
4
4
---
5
5
6
-
`gh stack modify` provides an interactive terminal UI for restructuring a stack locally. You can drop, fold, rename, and reorder branches and then apply all your changes at once.
6
+
`gh stack modify` provides an interactive terminal UI for restructuring a stack locally. You can drop, fold, insert, rename, and reorder branches and then apply all your changes at once.
@@ -12,6 +12,7 @@ description: How to use `gh stack modify` to restructure a stack.
12
12
Use `modify` when you need to:
13
13
-**Remove** a branch from the stack
14
14
-**Combine** two branches into one
15
+
-**Insert** a new branch into the stack
15
16
-**Rename** a branch
16
17
-**Reorder** branches
17
18
@@ -46,21 +47,25 @@ Absorbs the selected branch's commits into the branch below it (toward trunk) vi
46
47
47
48
Absorbs the selected branch's commits into the branch above it (away from trunk). Since the branch above already contains the folded branch's commits in its history, this is handled by adjusting what is considered the first unique commit for the branch. The folded branch is removed from the stack.
48
49
50
+
### Insert below / above (`i` / `I`)
51
+
52
+
Inserts a new empty branch into the stack at the cursor position. Lowercase `i` inserts below the cursor (toward trunk); uppercase `I` inserts above the cursor (away from trunk). An inline prompt appears to enter the new branch name. The branch is created at apply time, pointing at the parent branch's tip.
53
+
49
54
### Rename (`r`)
50
55
51
56
Opens an inline prompt to enter a new name for the branch. The branch is renamed locally and in the stack metadata. On the next `submit`, the new branch name is pushed to GitHub.
52
57
53
58
### Reorder (`Shift+↑`/`Shift+↓`)
54
59
55
-
Moves the selected branch up (away from trunk) or down (toward trunk) in the stack. A cascading rebase adjusts all affected branches. Note: reordering and structural changes (drop/fold/rename) cannot be mixed in the same session.
60
+
Moves the selected branch up (away from trunk) or down (toward trunk) in the stack. A cascading rebase adjusts all affected branches. Note: reordering and structural changes (drop/fold/insert/rename) cannot be mixed in the same session.
56
61
57
62
### Undo (`z`)
58
63
59
64
Reverses the most recent staged action. You can undo multiple times to step back through your changes.
60
65
61
66
## Applying changes
62
67
63
-
Press `Ctrl+S` to apply all staged changes. Nothing is modified until you save. The apply phase renames branches, folds/drops branches, and runs a cascading rebase to create a linear commit history with the desired stack state.
68
+
Press `Ctrl+S` to apply all staged changes. Nothing is modified until you save. The apply phase renames branches, inserts new branches, folds/drops branches, and runs a cascading rebase to create a linear commit history with the desired stack state.
64
69
65
70
### Handling conflicts
66
71
@@ -94,8 +99,7 @@ This also works if `modify` was interrupted (e.g., terminal crash). A pre-modify
94
99
## Limitations
95
100
96
101
- Cannot modify merged branches (they are locked)
97
-
- Cannot add new branches (use `gh stack add` instead)
98
102
- Cannot split a branch into multiple branches
99
103
- Cannot move branches between different stacks
100
104
- Requires an interactive terminal
101
-
- Reordering and structural changes (drop/fold/rename) cannot be mixed in the same session
105
+
- Reordering and structural changes (drop/fold/insert/rename) cannot be mixed in the same session
Copy file name to clipboardExpand all lines: docs/src/content/docs/guides/ui.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,7 +93,7 @@ Commits created by a server-side rebase are **not signed**. If your repository r
93
93
94
94
## Unstacking
95
95
96
-
If you want to reorder or reorganize the PRs in a stack, you must first dissolve the stack and then re-create it. You can unstack PRs from the UI.
96
+
If you want to reorder or reorganize the PRs in a stack from the UI, you must first dissolve the stack and then re-create it. For CLI users, `gh stack modify` provides an interactive way to [restructure a stack](/gh-stack/guides/modify/) — including reordering, inserting, dropping, and renaming branches — without needing to dissolve it.
Copy file name to clipboardExpand all lines: docs/src/content/docs/guides/workflows.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -299,7 +299,7 @@ All branches in a stack should be part of the same feature or project. If you ne
299
299
300
300
## Restructuring a Stack
301
301
302
-
When you need to change the composition of a stack — remove a branch, combine branches, change the order, or rename a branch — use `gh stack modify`:
302
+
When you need to change the composition of a stack — remove a branch, combine branches, insert a new branch, change the order, or rename a branch — use `gh stack modify`:
Copy file name to clipboardExpand all lines: docs/src/content/docs/introduction/overview.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,7 +89,8 @@ While the PR UI provides the review and merge experience, the `gh stack` CLI han
89
89
-**Creating PRs** — `gh stack submit` pushes branches and creates or updates PRs, linking them as a Stack on GitHub.
90
90
-**Navigating the stack** — `gh stack up`, `down`, `top`, and `bottom` let you move between layers without remembering branch names.
91
91
-**Syncing everything** — `gh stack sync` fetches, rebases, pushes, and updates PR state in one command.
92
-
-**Tearing down stacks** — `gh stack unstack` removes a stack from GitHub and local tracking if you need to restructure it.
92
+
-**Restructuring stacks** — `gh stack modify` opens an interactive terminal UI to drop, fold, insert, rename, and reorder branches in a stack.
93
+
-**Tearing down stacks** — `gh stack unstack` removes a stack from GitHub and local tracking.
93
94
-**Checking out a stack** — `gh stack checkout <pr-number>` pulls down a stack, with all its branches, from GitHub to your local machine.
94
95
95
96
The CLI is not required to use Stacked PRs — the underlying git operations are standard. But it makes the workflow simpler, and you can create Stacked PRs from the CLI instead of the UI.
Copy file name to clipboardExpand all lines: docs/src/content/docs/reference/cli.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -192,14 +192,16 @@ The command checks these conditions before opening the TUI:
192
192
| Drop |`x`| Remove branch and its commits from stack. Local branch and associated PR are preserved. |
193
193
| Fold down |`d`| Absorb commits into branch below (toward trunk). Folded branch removed from stack. |
194
194
| Fold up |`u`| Absorb commits into branch above (away from trunk). Folded branch removed from stack. |
195
+
| Insert below |`i`| Insert a new empty branch below the cursor (toward trunk). |
196
+
| Insert above |`I`| Insert a new empty branch above the cursor (away from trunk). |
195
197
| Move down |`Shift+↓`| Reorder branch down (toward trunk) in the stack |
196
198
| Move up |`Shift+↑`| Reorder branch up (away from trunk) in the stack |
197
199
| Rename |`r`| Rename the branch (opens inline prompt) |
198
200
| Undo |`z`| Undo the last staged action |
199
201
200
202
**Apply phase:**
201
203
202
-
When you press `Ctrl+S`, the staged changes are applied by renaming branches, folding/dropping branches, and running a cascading rebase to create a linear commit history with the desired stack state.
204
+
When you press `Ctrl+S`, the staged changes are applied by renaming branches, inserting new branches, folding/dropping branches, and running a cascading rebase to create a linear commit history with the desired stack state.
203
205
204
206
If a rebase conflict occurs, you can:
205
207
- Resolve conflicts, stage files, and run `gh stack modify --continue`
@@ -234,7 +236,7 @@ You must have a branch from the stack checked out locally. The command targets t
234
236
235
237
Deletes the stack on GitHub first, if it exists, then removes it from local tracking. If the remote deletion fails, the local state is left untouched so you can retry. Use `--local` to skip the remote deletion and only remove local tracking.
236
238
237
-
This is useful when you need to restructure a stack — remove 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.
239
+
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.
0 commit comments