Work with Graphite (gt) for stacked PRs - creating, navigating, and managing PR stacks.
Use Graphite (gt) for creating stacked branches locally, then submitting them as linked pull requests.
Graphite CLI v1 uses flat command names. Legacy aliases may still work, but prefer the current commands in this guide.
| I want to... | Command |
|---|---|
| Create a stacked branch | gt create [name] |
| Create with staged-all / message | gt create --all --message "message" |
| Amend or create a commit | gt modify |
| Add a new commit | gt modify --commit |
| Amend staged changes into a downstack branch | gt modify --into |
| Absorb staged hunks into existing commits | gt absorb |
| Split a branch | gt split |
| Squash a branch | gt squash |
| Restack the current stack | gt restack |
| Rebase onto another branch | gt move --onto <branch> |
| Reorder branches in a stack | gt reorder |
| Submit the current stack | gt submit |
| Submit descendants too | gt submit --stack |
| Sync local stack with remote | gt sync |
| Checkout a branch | gt checkout [branch] |
| Navigate up the stack | gt up [steps] |
| Navigate down the stack | gt down [steps] |
| Jump to the top | gt top |
| Jump to the bottom | gt bottom |
| Inspect stack structure | gt log short |
| Open the current PR | gt pr |
| Open the current stack page | gt pr --stack |
| Track a branch | gt track [branch] -p <parent> |
| Stop tracking a branch | gt untrack [branch] |
| Delete a branch but keep files | gt pop |
| Delete a branch locally | gt delete [name] |
| Fold a branch into its parent | gt fold |
| Undo the most recent mutation | gt undo |
Common aliases:
gt ls = gt log shortgt ll = gt log longgt sp = gt splitgt ss = gt submit --stackgit add or gt add.gt create [name].gt modify, gt absorb, gt split, or gt squash to shape the branch.gt restack if parents or ancestry changed.gt sync when you need to pull trunk updates and clean up merged branches.gt submit, or gt submit --stack if you want descendants included.git add <files>
gt create branch-name
If no branch name is provided, Graphite can generate one from the commit message.
git add <files>
gt modify -m "updated commit message"
Use -c, --commit to create a new commit instead of amending the current one, -a, --all to stage everything, and --into to amend staged changes into a downstack branch.
Use gt absorb when staged hunks should be moved into earlier commits in the current stack.
gt split breaks one branch into multiple branches by commit, hunk, or file. Use --by-commit, --by-hunk, or --by-file <pathspec>.gt squash combines the current branch into a single commit and restacks descendants.gt up
gt down
gt top
gt bottom
gt checkout
gt parent
gt children
gt trunk
Use gt log short or gt ls to inspect the stack layout, and gt log long or gt ll for the commit graph.
If a branch is untracked, start tracking it with gt track [branch] -p <parent>.
gt track -p main
gt restack
Use gt untrack [branch] to stop tracking a branch, and gt unlink [branch] to remove the PR association without deleting the branch. If Graphite metadata is corrupted, gt track [branch] can re-establish parent relationships.
For branch moves:
gt move --onto main
Use gt reorder when you want to rearrange branches between trunk and the current branch.
gt submit
Use gt submit --stack when you want to submit descendants of the current branch too.
Useful submit flags include:
--ai--always--branch--draft--edit--publish--update-only--restack--cli--web--no-edit--no-edit-title--no-edit-descriptiongt pr
gt pr --stack
gt pr opens the current branch PR. gt pr --stack opens the stack page.
gt delete [name] is local-only. It deletes the branch and restacks any children onto the parent branch. If the branch has an open PR, close it separately or use --close. Use --upstack or --downstack when you want to delete related branches too.
gt pop deletes the current branch but keeps the files in the working tree.
gt fold folds a branch into its parent, updates descendants, and restacks locally. If the branch has an open PR, close it separately. Use -k, --keep if you want to keep the current branch name.
gt completion sets up shell completion.gt config opens Graphite CLI configuration.gt aliases edits command aliases.gt aliases --legacy adds the legacy alias preset.gt auth adds the auth token needed to create and update GitHub PRs.gt docs opens the built-in docs.gt upgrade updates the CLI to the latest stable version.| Problem | Fix |
|---|---|
| Branch is untracked | Run gt track [branch] -p <tracked-parent> first. |
| Stack rooted on the wrong branch | Use gt track -p main and then gt restack. |
| Need to reorder branches | Use gt reorder. |
| Restack hits conflicts | Resolve them with git, then run gt continue. |
| Need to abandon a Graphite command blocked by a rebase conflict | Use gt abort. |
| Need the current branch's metadata | Use gt info or gt log short. |
gt commands over legacy alias spellings when writing examples or docs.gt docs or gt --help --all.