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
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,7 @@ Stack metadata is stored in `.git/gh-stack` (a JSON file, not committed to the r
69
69
Initialize a new stack in the current repository.
70
70
71
71
```
72
-
gh stack init [branches...] [flags]
72
+
gh stack init [flags] [branches...]
73
73
```
74
74
75
75
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`.
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.
@@ -190,7 +190,7 @@ gh stack checkout
190
190
Pull from remote and do a cascading rebase across the stack.
191
191
192
192
```
193
-
gh stack rebase [branch] [flags]
193
+
gh stack rebase [flags] [branch]
194
194
```
195
195
196
196
Fetches the latest changes from `origin`, then ensures each branch in the stack has the tip of the previous layer in its commit history. Rebases branches in order from trunk upward. If a branch's PR has been squash-merged, the rebase automatically switches to `--onto` mode to correctly replay commits on top of the merge target.
@@ -331,7 +331,7 @@ gh stack view --json
331
331
Remove a stack from local tracking and delete it on GitHub. Also available as `gh stack delete`.
332
332
333
333
```
334
-
gh stack unstack [branch] [flags]
334
+
gh stack unstack [flags] [branch]
335
335
```
336
336
337
337
If no branch is specified, uses the current branch to find the stack. Deletes the stack on GitHub first, then removes local tracking. Use `--local` to only remove the local tracking entry.
Create a short command alias so you can type less.
415
415
416
416
```
417
-
gh stack alias [name] [flags]
417
+
gh stack alias [flags] [name]
418
418
```
419
419
420
420
Installs a small wrapper script into `~/.local/bin/` that forwards all arguments to `gh stack`. The default alias name is `gs`, but you can choose any name by passing it as an argument. After setup, you can run `gs push` instead of `gh stack push`.
Copy file name to clipboardExpand all lines: docs/src/content/docs/faq.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
@@ -158,7 +158,7 @@ Yes, you can continue to use your tool of choice (e.g. jj, Sapling, ghstack, git
158
158
159
159
Stacked PRs on GitHub are based on the standard pull request model — any tool that creates PRs with the correct base branches can work with them. The `gh stack` CLI is purpose-built for the GitHub experience, but other tools that manage branch chains should be compatible.
160
160
161
-
You can also use the GitHub CLI in conjunction with other tools to simply create a stack of PRs:
161
+
You can also use the GitHub CLI in conjunction with other tools to open your PRs as a stack:
Copy file name to clipboardExpand all lines: docs/src/content/docs/guides/workflows.md
+10-7Lines changed: 10 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ gh stack rebase
33
33
# 7. Push the updated branches
34
34
gh stack push
35
35
36
-
# 8. When the first PR is merged, sync the stack
36
+
# 8. Sync upstream changes as PRs get merged
37
37
gh stack sync
38
38
```
39
39
@@ -42,34 +42,37 @@ gh stack sync
42
42
For speed, 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.
43
43
44
44
```sh
45
+
# Alias `gh stack` as `gs` for easier use
46
+
gh stack alias
47
+
45
48
# 1. Start a stack with numbered branches
46
-
gh stack init -p feat --numbered
49
+
gs init -p feat --numbered
47
50
# → creates feat/01 and checks it out
48
51
49
52
# 2. Write code for the first layer
50
53
# ... write code ...
51
54
52
55
# 3. Stage and commit on the current branch
53
-
gh stack add -Am "Auth middleware"
56
+
gs add -Am "Auth middleware"
54
57
# → feat/01 has no commits yet, so the commit lands here
55
58
56
59
# 4. Write code for the next layer
57
60
# ... write code ...
58
61
59
62
# 5. Create the next branch and commit
60
-
gh stack add -Am "API routes"
63
+
gs add -Am "API routes"
61
64
# → feat/01 already has commits, so feat/02 is created
62
65
63
66
# 6. Keep going
64
67
# ... write code ...
65
-
gh stack add -Am "Frontend components"
68
+
gs add -Am "Frontend components"
66
69
# → creates feat/03
67
70
68
71
# 7. Push everything and create PRs
69
-
gh stack submit
72
+
gs submit
70
73
```
71
74
72
-
Each `gh stack add -Am "..."` stages all files, commits, and (if the current branch already has commits) creates a new branch — no separate `git add` or `git commit` needed.
75
+
Each `gs add -Am "..."` stages all files, commits, and (if the current branch already has commits) creates a new branch — no separate `git add` or `git commit` needed.
Copy file name to clipboardExpand all lines: docs/src/content/docs/index.mdx
+14-9Lines changed: 14 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,37 +47,42 @@ A **stack** is a series of pull requests in the same repository where each PR ta
47
47
<Imagesrc={stackDiagram}alt="A stack of pull requests: main at the bottom, with auth-layer (PR #1), api-endpoints (PR #2), and frontend (PR #3) stacked on top" />
48
48
</div>
49
49
50
-
GitHub understands stacks end-to-end: the pull request UI shows a **stack map** so reviewers can navigate between layers, branch protection rules are enforced against the **final target branch** (not just the direct base), and CI runs for every PR in the stack.
50
+
GitHub understands stacks end-to-end: the pull request UI shows a **stack map** so reviewers can navigate between layers, branch protection rules are enforced against the **final target branch** (not just the direct base), and CI runs for every PR in the stack as if they were targeting the final branch.
<Imagesrc={stackNavigator}alt="The stack navigator in a pull request header" />
54
54
</div>
55
55
56
56
## How It Works
57
57
58
-
The `gh stack` CLI handles the local workflow: creating branches, keeping them rebased, pushing to GitHub, and creating PRs with the correct base branches. On GitHub, the PR UI gives reviewers the context they need — a stack map for navigation, focused diffs for each layer, and proper rules enforcement.
58
+
The `gh stack` CLI handles the local workflow: creating branches, managing rebases, pushing to GitHub, and creating PRs with the correct base branches. On GitHub, the PR UI gives reviewers the context they need — a stack map for navigation, focused diffs for each layer, and proper rules enforcement.
59
59
60
-
When you're ready to merge, you merge from the bottom up. Each PR can be merged directly or through the merge queue. When a PR at the bottom is merged, the remaining stack is automatically rebased so the next PR targets `main` and is ready for its own merge.
60
+
When you're ready to merge, you can merge all or a part of the stack. Each PR can be merged directly or through the merge queue. After a merge, the remaining PRs in the stack are automatically rebased so the lowest unmerged PR targets the base branch.
61
61
62
62
## Get Started
63
63
64
64
```sh
65
65
# Install the CLI extension
66
66
gh extension install github/gh-stack
67
67
68
-
# Create a stack (creates and checks out the first branch)
69
-
gh stack init auth-layer
68
+
# Alias `gh stack` as `gs` for easier use (optional)
69
+
gh stack alias
70
+
71
+
# Start a stack (creates and checks out the first branch)
72
+
gs init auth-layer
70
73
# ... make commits ...
71
-
gh stack add api-routes
74
+
75
+
# Create new layers in the stack (creates and checks out each new branch)
76
+
gs add api-routes
72
77
# ... make commits ...
73
-
gh stack add frontend
78
+
gs add frontend
74
79
# ... make commits ...
75
80
76
81
# Push all branches
77
-
gh stack push
82
+
gs push
78
83
79
84
# Open a stack of PRs
80
-
gh stack submit
85
+
gs submit
81
86
```
82
87
83
88
Ready to dive in? Start with the [Quick Start guide](/gh-stack/getting-started/quick-start/) or read the [full overview](/gh-stack/introduction/overview/).
Copy file name to clipboardExpand all lines: docs/src/content/docs/introduction/overview.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Overview
3
3
description: What stacked pull requests are, why they matter, and how GitHub supports them natively.
4
4
---
5
5
6
-
## The Challenge
6
+
## Why Stacks?
7
7
8
8
For developers who want to break large changes into smaller, dependent parts, the experience can be painful:
9
9
@@ -89,8 +89,9 @@ While the PR UI provides the review and merge experience, the `gh stack` CLI han
89
89
-**Navigating the stack** — `gh stack up`, `down`, `top`, and `bottom` let you move between layers without remembering branch names.
90
90
-**Syncing everything** — `gh stack sync` fetches, rebases, pushes, and updates PR state in one command.
91
91
-**Tearing down stacks** — `gh stack unstack` removes a stack from GitHub and local tracking if you need to restructure it.
92
+
-**Checking out a stack** — `gh stack checkout <pr-number>` pulls down a stack, with all its branches, from GitHub to your local machine.
92
93
93
-
The CLI is not required to use Stacked PRs — the underlying git operations are standard. But it makes the workflow dramatically simpler.
94
+
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 CLI instead of the UI.
Add a new branch on top of the current stack. Must be run while on the topmost branch (or the trunk if the stack has no branches yet). Always provide an explicit branch name.
425
425
426
426
```
427
-
gh stack add [branch] [flags]
427
+
gh stack add [flags] [branch]
428
428
```
429
429
430
430
**Recommended workflow — create the branch, then use standard git:**
@@ -578,7 +578,7 @@ gh stack sync [flags]
578
578
Pull from remote and cascade-rebase stack branches. Use this when `sync` reports a conflict or when you need finer control (e.g., rebase only part of the stack).
579
579
580
580
```
581
-
gh stack rebase [branch] [flags]
581
+
gh stack rebase [flags] [branch]
582
582
```
583
583
584
584
```bash
@@ -730,7 +730,7 @@ When a branch name is provided, the command resolves it against locally tracked
730
730
Tear down a stack so you can restructure it — 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.
0 commit comments