Skip to content

Commit e0495d5

Browse files
committed
unstack docs
1 parent c56277b commit e0495d5

4 files changed

Lines changed: 70 additions & 2 deletions

File tree

docs/src/content/docs/faq.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,24 @@ You can also add PRs to an existing stack from the GitHub UI. See [Adding to an
3333

3434
### How can I modify my stack?
3535

36-
Reordering or inserting branches into the middle of a stack is not currently supported. To restructure a stack, you need to delete it and recreate it with the desired order.
36+
Reordering or inserting branches into the middle of a stack is not currently supported. To restructure a stack, use `gh stack unstack` to tear it down and then recreate it with `gh stack init --adopt`:
37+
38+
```sh
39+
# 1. Remove the stack
40+
gh stack unstack
41+
42+
# 2. Make structural changes (reorder, rename, delete branches)
43+
git branch -m old-name new-name
44+
45+
# 3. Re-create the stack with the new structure
46+
gh stack init --adopt branch-2 branch-1 branch-3
47+
```
3748

3849
### How do I delete my stack?
3950

40-
You can unstack PRs from the GitHub UI — see [Unstacking](/gh-stack/guides/ui/#unstacking) for a walkthrough. This dissolves the association between PRs, turning them back into standard independent PRs. CLI support for unstacking is coming soon.
51+
**From the CLI** — Run `gh stack unstack` to delete the stack on GitHub and remove local tracking. Use `--local` to only remove local tracking.
52+
53+
**From the UI** — You can unstack PRs from the GitHub UI — see [Unstacking](/gh-stack/guides/ui/#unstacking) for a walkthrough. This dissolves the association between PRs, turning them back into standard independent PRs.
4154

4255
### Can stacks be created across forks?
4356

docs/src/content/docs/guides/workflows.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,27 @@ Create a new branch (`gh stack add`) when you're starting a **different concern*
163163

164164
All branches in a stack should be part of the same feature or project. If you need to work on something unrelated, start a separate stack with `gh stack init` or switch to an existing one with `gh stack checkout`.
165165

166+
## Restructuring a Stack
167+
168+
When you need to remove a branch, reorder branches, or rename branches, tear down the stack and rebuild it:
169+
170+
```sh
171+
# 1. Remove the stack on GitHub and locally
172+
gh stack unstack
173+
174+
# 2. Make structural changes
175+
git branch -m old-branch-1 new-branch-1 # rename a branch
176+
git branch -D branch-3 # delete a branch
177+
178+
# 3. Re-create the stack with the new order
179+
gh stack init --adopt new-branch-1 branch-2 branch-4
180+
181+
# 4. Push and sync the new stack
182+
gh stack submit
183+
```
184+
185+
The `unstack` command deletes the stack on GitHub first, then removes local tracking. Your branches and PRs are not affected — only the stack relationship is removed. After `init --adopt`, any existing open PRs are automatically re-associated with the new stack.
186+
166187
## Using AI Agents with Stacks
167188

168189
AI coding agents (like GitHub Copilot) can create and manage Stacked PRs on your behalf. Install the gh-stack skill to give them the context they need:

docs/src/content/docs/introduction/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ While the PR UI provides the review and merge experience, the `gh stack` CLI han
8888
- **Creating PRs**`gh stack submit` pushes branches and creates or updates PRs, linking them as a Stack on GitHub.
8989
- **Navigating the stack**`gh stack up`, `down`, `top`, and `bottom` let you move between layers without remembering branch names.
9090
- **Syncing everything**`gh stack sync` fetches, rebases, pushes, and updates PR state in one command.
91+
- **Tearing down stacks**`gh stack unstack` removes a stack from GitHub and local tracking if you need to restructure it.
9192

9293
The CLI is not required to use Stacked PRs — the underlying git operations are standard. But it makes the workflow dramatically simpler.
9394

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,39 @@ gh stack push
275275
gh stack push --remote upstream
276276
```
277277

278+
### `gh stack unstack`
279+
280+
Remove a stack from local tracking and delete it on GitHub.
281+
282+
```sh
283+
gh stack unstack [flags] [branch]
284+
```
285+
286+
Deletes the stack on GitHub first, 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.
287+
288+
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 --adopt` to re-create the stack with the desired structure.
289+
290+
| Flag | Description |
291+
|------|-------------|
292+
| `--local` | Only delete the stack locally (keep it on GitHub) |
293+
294+
| Argument | Description |
295+
|----------|-------------|
296+
| `[branch]` | A branch in the stack to identify which stack to delete (defaults to the current branch) |
297+
298+
**Examples:**
299+
300+
```sh
301+
# Delete the stack on GitHub and remove local tracking
302+
gh stack unstack
303+
304+
# Only remove local tracking
305+
gh stack unstack --local
306+
307+
# Specify a branch to identify which stack
308+
gh stack unstack feature-auth
309+
```
310+
278311
---
279312

280313
## Navigation

0 commit comments

Comments
 (0)