Skip to content

Commit a00ff54

Browse files
committed
link command for api-only operations (#50)
* link cmd for api-only stack upserts * accept branch names too * push branches first * update docs with link cmd details * adding more logging
1 parent 42e43a4 commit a00ff54

7 files changed

Lines changed: 1783 additions & 4 deletions

File tree

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,42 @@ gh stack submit --auto
307307
gh stack submit --draft
308308
```
309309

310+
### `gh stack link`
311+
312+
Link PRs into a stack on GitHub without local tracking.
313+
314+
```
315+
gh stack link [flags] <branch-or-pr> <branch-or-pr> [...]
316+
```
317+
318+
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.
319+
320+
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.
321+
322+
If the PRs are not yet in a stack, a new stack is created. If some of the PRs are already in a stack, the existing stack is updated to include the new PRs. Existing PRs are never removed from a stack — the update is additive only.
323+
324+
| Flag | Description |
325+
|------|-------------|
326+
| `--base <branch>` | Base branch for the bottom of the stack (default: `main`) |
327+
| `--draft` | Create new PRs as drafts |
328+
| `--remote <name>` | Remote to push to (defaults to auto-detected remote) |
329+
330+
**Examples:**
331+
332+
```sh
333+
# Link branches into a stack (pushes branches, creates PRs, creates stack)
334+
gh stack link feature-auth feature-api feature-ui
335+
336+
# Link existing PRs by number
337+
gh stack link 10 20 30
338+
339+
# Add branches to an existing stack of PRs
340+
gh stack link 42 43 feature-auth feature-ui
341+
342+
# Use a different base branch and create PRs as drafts
343+
gh stack link --base develop --draft feat-a feat-b feat-c
344+
```
345+
310346
### `gh stack view`
311347

312348
View the current stack.

0 commit comments

Comments
 (0)