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
* Accept PR URLs in link and checkout commands
Add support for GitHub PR URLs (e.g. https://github.com/owner/repo/pull/42)
as arguments to `gh stack link` and `gh stack checkout`, in addition to
the existing PR number and branch name support.
For `link`: PR URLs are parsed in findExistingPR before the numeric check.
Unlike numeric args, if a URL-extracted PR number doesn't exist, the command
errors immediately rather than falling through to branch name lookup (since
a URL can never be a valid branch name).
For `checkout`: PR URLs are parsed in runCheckout before the numeric check,
routing to resolveNumericTarget which supports both local and remote API
fallback — same behavior as passing a PR number directly.
Closes#115
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* update docs
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a PR number is provided (e.g. `123`), the command fetches the stack on GitHub, pulls the branches, and sets up the stack locally. If the stack already exists locally and matches, it switches to the branch. If the local and remote stacks have different compositions, you'll be prompted to resolve the conflict.
174
+
When a PR number or URL is provided (e.g. `123` or `https://github.com/owner/repo/pull/123`), the command fetches the stack on GitHub, pulls the branches, and sets up the stack locally. If the stack already exists locally and matches, it switches to the branch. If the local and remote stacks have different compositions, you'll be prompted to resolve the conflict.
175
175
176
176
When a branch name is provided, the command resolves it against locally tracked stacks only.
177
177
@@ -183,6 +183,9 @@ When run without arguments in an interactive terminal, shows a menu of all local
@@ -389,7 +392,7 @@ Link PRs into a stack on GitHub without local tracking.
389
392
gh stack link [flags] <branch-or-pr> <branch-or-pr> [...]
390
393
```
391
394
392
-
Creates or updates a stack on GitHub from branch names or PR numbers. This command does not store or modify any `gh stack` local tracking state. It is designed for users who manage branches with other tools locally (e.g., jj, Sapling, git-town) and want to simply open a stack of PRs.
395
+
Creates or updates a stack on GitHub from branch names or PR numbers/URLs. This command does not store or modify any `gh stack` local tracking state. It is designed for users who manage branches with other tools locally (e.g., jj, Sapling, git-town) and want to simply open a stack of PRs.
393
396
394
397
Arguments are provided in stack order (bottom to top). Branch arguments are automatically pushed to the remote before creating or looking up PRs. For branches that already have open PRs, those PRs are used. For branches without PRs, new PRs are created automatically with the correct base branch chaining. Existing PRs whose base branch doesn't match the expected chain are corrected automatically.
395
398
@@ -410,6 +413,9 @@ gh stack link feature-auth feature-api feature-ui
410
413
# Link existing PRs by number
411
414
gh stack link 10 20 30
412
415
416
+
# Link existing PRs by URL
417
+
gh stack link https://github.com/owner/repo/pull/10 https://github.com/owner/repo/pull/20
Copy file name to clipboardExpand all lines: docs/src/content/docs/introduction/overview.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
@@ -91,7 +91,7 @@ While the PR UI provides the review and merge experience, the `gh stack` CLI han
91
91
-**Syncing everything** — `gh stack sync` fetches, rebases, pushes, and updates PR state in one command.
92
92
-**Restructuring stacks** — `gh stack modify` opens an interactive terminal UI to drop, fold, insert, rename, and reorder branches in a stack.
93
93
-**Tearing down stacks** — `gh stack unstack` removes a stack from GitHub and local tracking.
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
+
-**Checking out a stack** — `gh stack checkout <pr-number|url>` pulls down a stack, with all its branches, from GitHub to your local machine.
95
95
96
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
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -135,13 +135,13 @@ gh stack view --json
135
135
136
136
### `gh stack checkout`
137
137
138
-
Check out a stack from a pull request number or branch name.
138
+
Check out a stack from a pull request number, URL, or branch name.
139
139
140
140
```sh
141
-
gh stack checkout [<pr-number>|<branch>]
141
+
gh stack checkout [<pr-number>|<pr-url>|<branch>]
142
142
```
143
143
144
-
When a PR number is provided (e.g., `123`), the command fetches the stack on GitHub, pulls the branches, and sets up the stack locally. If the stack already exists locally and matches, it switches to the branch. If the local and remote stacks have different compositions, you'll be prompted to resolve the conflict.
144
+
When a PR number or URL is provided (e.g., `123` or `https://github.com/owner/repo/pull/123`), the command fetches the stack on GitHub, pulls the branches, and sets up the stack locally. If the stack already exists locally and matches, it switches to the branch. If the local and remote stacks have different compositions, you'll be prompted to resolve the conflict.
145
145
146
146
When a branch name is provided, the command resolves it against locally tracked stacks only.
147
147
@@ -153,6 +153,9 @@ When run without arguments in an interactive terminal, shows a menu of all local
@@ -391,7 +394,7 @@ Link PRs into a stack on GitHub without local tracking.
391
394
gh stack link [flags] <branch-or-pr><branch-or-pr> [...]
392
395
```
393
396
394
-
Creates or updates a stack on GitHub from branch names or PR numbers. This command does not create or modify any `gh-stack` local tracking state. It is designed for users who manage branches with other tools locally (e.g., jj, Sapling, git-town) and want to simply open a stack of PRs.
397
+
Creates or updates a stack on GitHub from branch names or PR numbers/URLs. This command does not create or modify any `gh-stack` local tracking state. It is designed for users who manage branches with other tools locally (e.g., jj, Sapling, git-town) and want to simply open a stack of PRs.
395
398
396
399
Arguments are provided in stack order (bottom to top). Branch arguments are automatically pushed to the remote before creating or looking up PRs. For branches that already have open PRs, those PRs are used. For branches without PRs, new PRs are created automatically with the correct base branch chaining. Existing PRs whose base branch doesn't match the expected chain are corrected automatically.
397
400
@@ -412,6 +415,9 @@ gh stack link feature-auth feature-api feature-ui
412
415
# Link existing PRs by number
413
416
gh stack link 10 20 30
414
417
418
+
# Link existing PRs by URL
419
+
gh stack link https://github.com/owner/repo/pull/10 https://github.com/owner/repo/pull/20
0 commit comments