Remarque
This feature is in public preview and subject to change.
Stacked pull requests are built on standard Git branches and regular pull requests, so you can choose to use tools other than the gh stack CLI for your local workflow. If you manage branch chains with another tool, such as Jujutsu (jj), Sapling, or git-town, you can use the gh stack link command to open those branches as a stack on GitHub.
The gh stack link command only calls the GitHub API to create the stacked pull requests — it does not create any local tracking. If a branch already has an open pull request, link uses it; otherwise it creates a draft pull request with the correct base branch.
Linking branches as a stack
-
Create your chain of branches locally with your tool of choice. For example, with Jujutsu:
jj new main -m "first change" jj bookmark create change1 --revision @ jj new -m "second change" jj bookmark create change2 --revision @ jj new -m "third change" jj bookmark create change3 --revision @ -
Push the branches and link them as a stack, listed from bottom to top.
gh stack link change1 change2 change3This pushes the branches, creates a pull request for each one with the correct base, and links them as a stack on GitHub.
Adding to an existing stack
To add more branches to a stack you created with link, run gh stack link again with the full list of pull requests and branches in the stack, from bottom to top. You can refer to existing pull requests by number.
gh stack link 123 124 125 change4 change5
Setting a base branch or opening pull requests
By default, link targets your repository's default branch and creates draft pull requests. To change this behavior:
- Use
--baseto specify a different trunk branch. - Use
--opento mark the pull requests as ready for review instead of draft.
gh stack link --base develop --open change1 change2 change3
Adopting branches for full local tracking
If you want full local stack tracking — so you can use commands like gh stack rebase, gh stack sync, and stack navigation — adopt your existing branches with gh stack init instead, then submit them.
gh stack init change1 change2 change3
gh stack submit