Note
This reference reflects the updated Graphite commands as of V1.0.0, which was released on 2023-09-13. The legacy commands will still be functional, but the CLI will prompt you to use the new command names. We will eventually deprecate the legacy commands in future versions.
See more information about the legacy command names.
Global flags
Name | Default | Type | Description |
---|---|---|---|
--cwd | null | string | Working directory in which to perform operations. |
--debug | false | boolean | Write debug output to a file. |
--interactive | true | boolean | Enable interactive features like prompts, pagers, and editors. Enabled by default. Disable with --no-interactive. |
--verify | true | boolean | Enable git hooks. Enabled by default. Disable with --no-verify. |
--quiet | false | boolean | Minimize output to the terminal. Implies --no-interactive. |
Available commands
Flags
name | type | description |
---|---|---|
--reset | boolean | Reset your alias configuration. |
Flags
name | alias | type | description |
---|---|---|---|
--token | -t | string | Auth token. Get it from: https://app.graphite.dev/activate |
gt checkout [branch]
gt co
Switch to a branch. If no branch is provided, opens an interactive selector.
branch
(optional)
The branch to checkout.
Flags
name | alias | type | description |
---|---|---|---|
--show-untracked | -u | boolean | Include untracked branches in interactive selection. |
Flags
name | alias | type | description |
---|---|---|---|
--all | -a | boolean | Stage all changes before continuing. |
gt create [name]
gt c
Create a new branch stacked on top of the current branch and commit staged changes. If no branch name is specified, generate a branch name from the commit message. If your working directory contains no changes, an empty branch will be created. If you have any unstaged changes, you will be asked whether you'd like to stage them.
name
(optional)
The name of the new branch.
Flags
name | alias | type | description |
---|---|---|---|
--all | -a | boolean | Stage all unstaged changes before creating the branch, including to untracked files. |
--insert | -i | boolean | Insert this branch between the current branch and its child. If there are multiple children, prompts you to select which should be moved onto the new branch. |
--message | -m | string | Specify a commit message. |
--patch | -p | boolean | Pick hunks to stage before committing. |
gt delete [name]
gt dl
Delete a branch and its Graphite metadata. Children will be restacked onto the parent branch. If the branch is not merged or closed, prompts for confirmation.
name
(optional)
The name of the branch to delete. If no branch is provided, opens an interactive selector.
Flags
name | alias | type | description |
---|---|---|---|
--force | -f | boolean | Delete the branch even if it is not merged or closed. |
Flags
name | alias | type | description |
---|---|---|---|
--steps | -n | number | The number of levels to traverse downstack. |
gt feedback [message]
Post a string directly to the maintainers' Slack so they can drown in praise, factor in your feedback, laugh at your jokes, cry at your insults, or fall victim to Slack injection attacks.
message
(optional)
Positive or constructive feedback for the Graphite team! Jokes are chill too.
Flags
name | type | description |
---|---|---|
--print-debug-context | boolean | Print a debug summary of your repo. Useful for creating bug report details. |
--with-debug-context | boolean | Include a blob of json describing your repo's state to help with debugging. Run 'gt feedback --print-debug-context' to see what would be included. |
gt fold
Fold a branch's changes into its parent, update dependencies of descendants of the new combined branch, and restack.
Flags
name | alias | type | description |
---|---|---|---|
--keep | -k | boolean | Keeps the name of the current branch instead of using the name of its parent. |
gt get [branch]
Get branches from trunk to the specified branch from remote, prompting the user to resolve conflicts. If no branch is provided, get downstack from the current branch.
branch
(optional)
Branch to get from remote.
Flags
name | alias | type | description |
---|---|---|---|
--force | -f | boolean | Overwrite all fetched branches with remote source of truth |
Flags
name | alias | type | description |
---|---|---|---|
--body | -b | boolean | Show the PR body, if it exists. |
--diff | -d | boolean | Show the diff between this branch and its parent. Takes precedence over patch. |
--patch | -p | boolean | Show the changes made by each commit. |
--stat | -s | boolean | Show a diffstat instead of a full diff. Modifies either --patch or --diff. If neither is passed, implies --diff. |
gt init
Initialize Graphite in this repository by selecting a trunk branch. Can also be used to change the trunk branch of the repository.
Flags
name | type | description |
---|---|---|
--reset | boolean | Untrack all branches. |
--trunk | string | The name of your trunk branch. If no name is passed, you will be prompted to select one interactively. |
gt log [command]
gt l
Commands that log your stacks.
Has three forms, gt log
, gt log short
, and gt log long
.
gt log long
ignores all options and displays a graph of the commit ancestry of all branches.
gt log
and gt log short
display all tracked branches and their dependency relationships.
The difference between the latter two is that gt log
displays more information about each branch.
gt ls
and gt ll
are default aliases for gt log short
and gt log long
, respectively.
Flags
name | alias | type | description |
---|---|---|---|
--classic | boolean | Use the old short logging style, which runs out of screen real estate more quickly. Other options will not work in classic mode. | |
--reverse | -r | boolean | Print the log upside down. Handy when you have a lot of branches! |
--show-untracked | -u | boolean | Include untracked branches in the log. |
--stack | -s | boolean | Only show ancestors and descendants of the current branch. |
--steps | -n | number | Only show this many levels upstack and downstack. Implies --stack. |
gt merge
Merge the pull requests associated with all branches from trunk to the current branch via Graphite.
Flags
name | alias | type | description |
---|---|---|---|
--confirm | -c | boolean | Asks for confirmation before merging branches. Prompts for confirmation if the local branches differ from remote, regardless of the value of this flag. |
--dry-run | boolean | Reports the PRs that would be merged and terminates. No branches are merged. |
gt modify
gt m
Modify the current branch by amending its commit or creating a new commit. Automatically restacks descendants. If you have any unstaged changes, you will be asked whether you'd like to stage them.
Flags
name | alias | type | description |
---|---|---|---|
--all | -a | boolean | Stage all changes before committing. |
--commit | -c | boolean | Create a new commit instead of amending the current commit. If this branch has no commits, this command always creates a new commit. |
--edit | -e | boolean | If passed, open an editor to edit the commit message. When creating a new commit, this flag is ignored. |
--interactive-rebase | boolean | Ignore all other flags and start a git interactive rebase on the commits in this branch. | |
--message | -m | string | The message for the new or amended commit. If passed, no editor is opened. |
--patch | -p | boolean | Pick hunks to stage before committing. |
gt move
Rebase the current branch onto the target branch and restack all of its descendants. If no branch is passed in, opens an interactive selector.
Flags
name | alias | type | description |
---|---|---|---|
--onto | -o | string | Branch to move the current branch onto. |
--source | string | Branch to move (defaults to current branch). |
gt rename [name]
gt rn
Rename a branch and update metadata referencing it. If no branch name is supplied, you will be prompted for a new branch name. Note that this removes any association to a pull request, as GitHub pull request branch names are immutable.
name
(optional)
The new name for the current branch.
Flags
name | alias | type | description |
---|---|---|---|
--force | -f | boolean | Allow renaming a branch that is already associated with an open GitHub pull request. |
gt restack
gt r
Ensure each branch in the current stack has its parent in its Git commit history, rebasing if necessary. If conflicts are encountered, you will be prompted to resolve them via an interactive Git rebase.
Flags
name | type | description |
---|---|---|
--branch | string | Which branch to run this command from. Defaults to the current branch. |
--downstack | boolean | Only restack this branch and its ancestors. |
--only | boolean | Only restack this branch. |
--upstack | boolean | Only restack this branch and its descendants. |
gt revert [sha]
Create a branch that reverts a commit on the trunk branch. Currently experimental.
sha
(optional)
The commit to revert.
Flags
name | alias | type | description |
---|---|---|---|
--edit | -e | boolean | Edit the commit message. |
Flags
name | alias | type | description |
---|---|---|---|
--by-commit | -c , --commit | boolean | Split by commit - slice up the history of this branch. |
--by-hunk | -h , --hunk | boolean | Split by hunk - split into new single-commit branches. |
gt squash
gt sq
Squash all commits in the current branch into a single commit and restack upstack branches.
Flags
name | alias | type | description |
---|---|---|---|
--edit | boolean | Modify the existing commit message. | |
--message | -m | string | The updated message for the commit. |
--no-edit | -n | boolean | Don't modify the existing commit message. Takes precedence over --edit |
gt submit
gt s
Idempotently force push all branches from trunk to the current branch to GitHub, creating or updating distinct pull requests for each. Validates that branches are properly restacked before submitting, and fails if there are conflicts. Blocks force pushes to branches that overwrite branches that have changed since you last submitted or got them. Opens an interactive prompt that allows you to input pull request metadata. gt ss
is a default alias for gt submit --stack
.
Flags
name | alias | type | description |
---|---|---|---|
--always | boolean | Always push updates, even if the branch has not changed. Can be helpful for fixing an inconsistent Graphite stack view on Web/GitHub resulting from downtime/a bug. | |
--branch | string | Which branch to run this command from. Defaults to the current branch. | |
--confirm | -c | boolean | Reports the PRs that would be submitted and asks for confirmation before pushing branches and opening/updating PRs. If either of --no-interactive or --dry-run is passed, this flag is ignored. |
--draft | -d | boolean | If set, marks all PRs being submitted as draft. If --no-interactive is true, new PRs will be created in draft mode. |
--dry-run | boolean | Reports the PRs that would be submitted and terminates. No branches are restacked or pushed and no PRs are opened or updated. | |
--edit | -e | boolean | Input metadata for all PRs interactively. If neither --edit nor --no-edit is passed, only prompts for new PRs. |
--force | -f | boolean | Force push: overwrites the remote branch with your local branch. Otherwise defaults to --force-with-lease. |
--merge-when-ready | -m | boolean | If set, marks all PRs being submitted as merge when ready, which will let them automatically merge as soon as all merge requirements are met. |
--no-edit | -n | boolean | Don't edit any PR fields inline. Takes precedence over --edit |
--publish | -p | boolean | If set, publishes all PRs being submitted. If --no-interactive is true, new PRs will be created in draft mode. |
--rerequest-review | boolean | Rerequest review from current reviewers | |
--reviewers | -r | string | If set without an argument, prompt to manually set reviewers. Alternatively, accepts a comma separated string of reviewers |
--stack | -s | boolean | Submit descendants of the current branch in addition to its ancestors. |
--update-only | -u | boolean | Only push branches and update PRs for branches that already have PRs open. |
gt sync
Pull the trunk branch from remote and prompt to delete any branches that have been merged. Restacks all branches in your repository that can be restacked without conflicts. If trunk cannot be fast-forwarded to match remote, overwrites trunk with the remote version.
Flags
name | alias | type | description |
---|---|---|---|
--delete | boolean | Delete merged branches (true by default; skip with --no-delete). | |
--force | -f | boolean | Don't prompt for confirmation before deleting a branch or overwriting trunk to match remote if it can't be fast-forwarded. |
--pull | boolean | Pull the trunk branch from remote (true by default; skip with --no-pull). | |
--restack | boolean | Restack any branches that can be restacked without conflicts (true by default; skip with --no-restack). | |
--show-delete-progress | boolean | Show progress through merged branches. |
gt track [branch]
gt tr
Start tracking the current (or provided) branch with Graphite by selecting its parent. Can recursively track a stack of branches by specifying each branch's parent interactively. This command can also be used to fix corrupted Graphite metadata.
branch
(optional)
Branch to begin tracking. Defaults to the current branch.
Flags
name | alias | type | description |
---|---|---|---|
--force | -f | boolean | Sets the parent to the most recent tracked ancestor of the branch being tracked to skip prompts. Takes precedence over --parent |
--parent | -p | string | The tracked branch's parent. Must be set to a tracked branch. If provided, only one branch can be tracked at a time. |
gt untrack [branch]
gt utr
Stop tracking a branch with Graphite. If the branch has children, they will also be untracked. Default to the current branch if none is passed in.
branch
(optional)
Branch to stop tracking.
Flags
name | alias | type | description |
---|---|---|---|
--force | -f | boolean | Will not prompt for confirmation before untracking a branch with children. |