Skip to content

Commit eb9ad81

Browse files
committed
docs updates
1 parent 1710098 commit eb9ad81

7 files changed

Lines changed: 80 additions & 85 deletions

File tree

README.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,28 @@ Fetch, rebase, push, and sync PR state in a single command.
316316
gh stack sync [flags]
317317
```
318318

319-
Performs a safe, non-interactive synchronization of the entire stack:
319+
Performs a synchronization of the entire stack:
320320

321-
1. **Fetch** — fetches the latest changes from `origin`
322-
2. **Fast-forward trunk** — fast-forwards the trunk branch to match the remote (skips if diverged)
323-
3. **Cascade rebase** — rebases all stack branches onto their updated parents (only if trunk moved). If a conflict is detected, all branches are restored to their original state and you are advised to run `gh stack rebase` to resolve conflicts interactively
324-
4. **Push** — pushes all branches (uses `--force-with-lease` if a rebase occurred)
325-
5. **Sync PRs** — syncs PR state from GitHub and reports the status of each PR
326-
6. **Sync the stack** — links the stack's open PRs into a stack on GitHub, creating the remote stack object if it doesn't exist yet or updating it if it's partially formed. Only happens when two or more PRs exist; sync never opens PRs (use `gh stack submit` for that)
327-
7. **Prune** — in interactive terminals, prompts to delete local branches for merged PRs. Use `--prune` to prune automatically
321+
1. **Fetch** — fetches the latest changes from `origin`.
322+
2. **Reconcile the remote stack** — mirrors the GitHub stack locally. When PRs have been added to the stack on GitHub (the remote is ahead of your local stack), their branches are pulled down and appended to your local stack automatically. When the local and remote stacks have genuinely diverged (for example, you added a branch locally while different PRs were added to the stack on GitHub), you are prompted to resolve (see [Diverged stacks](#diverged-stacks) below). In a non-interactive terminal a divergence aborts the sync (nothing is pushed or updated).
323+
3. **Fast-forward trunk** — fast-forwards the trunk branch to match the remote (skips if diverged).
324+
4. **Cascade rebase** — rebases all stack branches onto their updated parents (only if trunk moved). If a conflict is detected, all branches are restored to their original state, and you are advised to run `gh stack rebase` to resolve conflicts interactively.
325+
5. **Push** — pushes all branches (uses `--force-with-lease` if a rebase occurred).
326+
6. **Sync PRs** — syncs PR state from GitHub and reports the status of each PR.
327+
7. **Sync the stack** — links the stack's open PRs into a stack on GitHub, creating the remote stack object if it doesn't exist yet or updating it if it's partially formed. This only happens when two or more PRs exist; sync never opens PRs (use `gh stack submit` for that).
328+
8. **Prune** — in interactive terminals, prompts to delete local branches for merged PRs. Use `--prune` to prune automatically.
329+
330+
A clean remote-ahead update (PRs added on top of your local stack) is pulled down automatically without prompting, so `sync` is safe to run in automation. Sync only prompts when the stacks have truly diverged.
331+
332+
#### Diverged stacks
333+
334+
When neither stack is a clean prefix of the other — for example, you added a branch locally while separate PRs were added to the same stack on GitHub — sync cannot merge the two automatically. In an interactive terminal it offers three choices:
335+
336+
- **Use the remote stack as the source of truth** — replaces your local stack composition with the remote's, pulling any missing branches. If you were on a branch that the remote stack no longer contains, you're moved to the nearest surviving branch. Requires a clean working state with no uncommitted changes.
337+
- **Delete the stack on GitHub** — deletes the stack object on GitHub and stops the sync. Your PRs and local branches are untouched (only the stack on GitHub is removed); recreate the stack with `gh stack submit` (run `gh stack modify` first if you want to change its structure). This is the way to make GitHub match your local stack, because `submit` — unlike `sync` — also creates PRs for any branches you haven't submitted yet.
338+
- **Cancel** — aborts the sync without pushing branches or updating any PRs.
339+
340+
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.
328341

329342
| Flag | Description |
330343
|------|-------------|
@@ -377,6 +390,8 @@ If every PR in the stack has already been merged, that stack is complete and can
377390

378391
In an interactive terminal, `submit` opens a full-screen, mouse- and keyboard-driven editor on a single screen. Every branch without a PR is included by default — deselect any you don't want on the left panel (<kbd>Ctrl</kbd>+<kbd>X</kbd>). Because each PR builds on the branch below it, deselecting a branch also deselects the ones stacked above it, and re-including a branch re-includes the ones below it. Draft each PR's title, description (with a markdown preview and `$EDITOR` escape), and choose ready-for-review or draft on the right, then submit them all at once with <kbd>Ctrl</kbd>+<kbd>S</kbd>. Pass `--auto` (or run in CI) to skip the editor and use auto-generated titles.
379392

393+
If the branches already have open PRs but no stack exists on GitHub, you will have the option to link the PRs into a stack with <kbd>Ctrl</kbd>+<kbd>B</kbd>.
394+
380395
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`.
381396

382397
| Flag | Description |

docs/package-lock.json

Lines changed: 0 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/src/content/docs/guides/stacked-prs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ gh stack sync
5151

5252
- **`gh stack push`** pushes branches only (uses `--force-with-lease` for safety). It does not create or update PRs.
5353
- **`gh stack submit`** pushes branches and creates or updates PRs, linking them as a Stack on GitHub.
54-
- **`gh stack sync`** is the all-in-one command: fetch, rebase, push, sync PR state, link open PRs into a Stack on GitHub, and optionally prune local branches for merged PRs.
54+
- **`gh stack sync`** is the all-in-one command: fetch, rebase, push, sync stack/PR state, link open PRs into a Stack on GitHub, and optionally prune local branches for merged PRs. If there is a divergence between local and remote stacks, you will be prompted to resolve.

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,28 @@ gh stack sync
130130

131131
This command:
132132
1. Fetches the latest changes from the remote
133-
2. Fast-forwards the trunk branch
134-
3. Rebases all remaining stack branches onto the updated trunk
135-
4. Pushes the updated branches
136-
5. Syncs PR state from GitHub
137-
6. Links the open PRs into a Stack on GitHub (creating or updating the remote stack when two or more PRs exist)
138-
7. Prompts to prune local branches for merged PRs (use `--prune` to prune automatically)
133+
2. Reconciles the remote stack with your local stack
134+
3. Fast-forwards the trunk branch
135+
4. Rebases all remaining stack branches onto the updated trunk
136+
5. Pushes the updated branches
137+
6. Syncs PR state from GitHub
138+
7. Links the open PRs into a Stack on GitHub (creating or updating the remote stack when two or more PRs exist)
139+
8. Prompts to prune local branches for merged PRs (use `--prune` to prune automatically)
139140

140141
If a conflict is detected during the rebase, all branches are restored to their original state, and you're advised to run `gh stack rebase` to resolve conflicts interactively.
141142

143+
### Pulling in PRs added to the stack on GitHub
144+
145+
If PRs are added to the stack on GitHub by someone else, `gh stack sync` fetches the new PRs' branches and appends them to your local stack so it mirrors the remote.
146+
147+
If your local and remote stacks have diverged — for example, you added a branch locally while different PRs/branches were added to the same stack on GitHub — sync can't merge them automatically. In an interactive terminal it offers three choices:
148+
149+
- **Use the remote stack as the source of truth** — replaces your local stack composition with the remote's, pulling any missing branches. If you were on a branch that the remote stack no longer contains, you're moved to the nearest surviving branch. Requires a clean working state with no uncommitted changes.
150+
- **Delete the stack on GitHub** — deletes the stack object on GitHub and stops the sync. Your PRs and local branches are untouched (only the stack on GitHub is removed); recreate the stack with `gh stack submit` (run `gh stack modify` first if you want to change its structure). This is the way to make GitHub match your local stack, because `submit` — unlike `sync` — also creates PRs for any branches you haven't submitted yet.
151+
- **Cancel** — aborts the sync without pushing branches or updating any PRs.
152+
153+
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.
154+
142155
## Rebasing Your Stack
143156

144157
Stacked PRs rely on rebasing rather than merge commits to keep each branch's diff clean and reviewable. If you're coming from a merge-commit workflow, the key difference is: instead of merging upstream changes into your branch (which creates a merge commit with multiple parents), you replay your commits on top of the latest base. The result is a linear history where each PR shows only its specific changes.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ While the PR UI provides the review and merge experience, the `gh stack` CLI han
8888
- **Pushing branches**`gh stack push` pushes all branches to the remote.
8989
- **Creating PRs**`gh stack submit` pushes branches and creates or updates PRs, linking them as a Stack on GitHub.
9090
- **Navigating the stack**`gh stack up`, `down`, `top`, and `bottom` let you move between layers without remembering branch names.
91-
- **Syncing everything**`gh stack sync` fetches, rebases, pushes, updates PR state, and links open PRs into a Stack on GitHub in one command.
91+
- **Syncing everything**`gh stack sync` fetches, rebases, pushes, updates PR state, and links open PRs into a Stack on GitHub in one command. It also syncs the stack's remote state, pulling down branches for any PRs added to the stack on GitHub.
9292
- **Restructuring stacks**`gh stack modify` opens an interactive terminal UI to drop, fold, insert, rename, and reorder branches in a stack.
9393
- **Tearing down stacks**`gh stack unstack` removes a stack from GitHub and local tracking.
9494
- **Checking out a stack**`gh stack checkout <pr-number|url>` pulls down a stack, with all its branches, from GitHub to your local machine.

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

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ In an interactive terminal, `submit` opens a full-screen editor on a single scre
278278

279279
Press <kbd>Ctrl</kbd>+<kbd>S</kbd> to submit all included PRs at once. The editor supports both keyboard and mouse input. Pass `--auto` (or run in a non-interactive terminal, such as CI) to skip the editor and use auto-generated titles.
280280

281+
If the branches already have open PRs but no stack exists on GitHub, you will have the option to link the PRs into a stack with <kbd>Ctrl</kbd>+<kbd>B</kbd>.
282+
281283
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`.
282284

283285
| Flag | Description |
@@ -302,15 +304,28 @@ Fetch, rebase, push, and sync PR state in a single command.
302304
gh stack sync [flags]
303305
```
304306

305-
Performs a safe, non-interactive synchronization of the entire stack:
307+
Performs a synchronization of the entire stack:
306308

307309
1. **Fetch** — fetches the latest changes from `origin`.
308-
2. **Fast-forward trunk** — fast-forwards the trunk branch to match the remote (skips if diverged).
309-
3. **Cascade rebase** — rebases all stack branches onto their updated parents (only if trunk moved). If a conflict is detected, all branches are restored to their original state, and you are advised to run `gh stack rebase` to resolve conflicts interactively.
310-
4. **Push** — pushes all branches (uses `--force-with-lease` if a rebase occurred).
311-
5. **Sync PRs** — syncs PR state from GitHub and reports the status of each PR.
312-
6. **Sync the stack** — links the stack's open PRs into a stack on GitHub, creating the remote stack object if it doesn't exist yet or updating it if it's partially formed. This only happens when two or more PRs exist; sync never opens PRs (use `gh stack submit` for that).
313-
7. **Prune** — in interactive terminals, prompts to delete local branches for merged PRs. Use `--prune` to prune automatically.
310+
2. **Reconcile the remote stack** — mirrors the GitHub stack locally. When PRs have been added to the stack on GitHub (the remote is ahead of your local stack), their branches are pulled down and appended to your local stack automatically. When the local and remote stacks have genuinely diverged (for example, you added a branch locally while different PRs were added to the stack on GitHub), you are prompted to resolve (see [Diverged stacks](#diverged-stacks) below). In a non-interactive terminal a divergence aborts the sync (nothing is pushed or updated).
311+
3. **Fast-forward trunk** — fast-forwards the trunk branch to match the remote (skips if diverged).
312+
4. **Cascade rebase** — rebases all stack branches onto their updated parents (only if trunk moved). If a conflict is detected, all branches are restored to their original state, and you are advised to run `gh stack rebase` to resolve conflicts interactively.
313+
5. **Push** — pushes all branches (uses `--force-with-lease` if a rebase occurred).
314+
6. **Sync PRs** — syncs PR state from GitHub and reports the status of each PR.
315+
7. **Sync the stack** — links the stack's open PRs into a stack on GitHub, creating the remote stack object if it doesn't exist yet or updating it if it's partially formed. This only happens when two or more PRs exist; sync never opens PRs (use `gh stack submit` for that).
316+
8. **Prune** — in interactive terminals, prompts to delete local branches for merged PRs. Use `--prune` to prune automatically.
317+
318+
A clean remote-ahead update (PRs added on top of your local stack) is pulled down automatically without prompting, so `sync` is safe to run in automation. Sync only prompts when the stacks have truly diverged.
319+
320+
#### Diverged stacks
321+
322+
When neither stack is a clean prefix of the other — for example, you added a branch locally while separate PRs were added to the same stack on GitHub — sync cannot merge the two automatically. In an interactive terminal it offers three choices:
323+
324+
- **Use the remote stack as the source of truth** — replaces your local stack composition with the remote's, pulling any missing branches. If you were on a branch that the remote stack no longer contains, you're moved to the nearest surviving branch. Requires a clean working state with no uncommitted changes.
325+
- **Delete the stack on GitHub** — deletes the stack object on GitHub and stops the sync. Your PRs and local branches are untouched (only the stack on GitHub is removed); recreate the stack with `gh stack submit` (run `gh stack modify` first if you want to change its structure). This is the way to make GitHub match your local stack, because `submit` — unlike `sync` — also creates PRs for any branches you haven't submitted yet.
326+
- **Cancel** — aborts the sync without pushing branches or updating any PRs.
327+
328+
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.
314329

315330
| Flag | Description |
316331
|------|-------------|

0 commit comments

Comments
 (0)