While you can find a full list of
gt commands in the command reference further down the docs page, there are a few commands/combinations of commands we find our engineers and power users use very frequently on a day-to-day basis. For your convenience, we've grouped these commands by their primary function, and included their equivalent command in
git (if relevant).
Basic workflow commands
These are commands that we're using constantly whenever we're creating and pushing changes to a repository with Graphite.
gt log short (gt ls)
This might be glaringly obvious, but any time branches are created/manipulated/changed, we run this command as if it were second nature. Most of our engineers prefer the truncated (
ls) log to the full log.
gt branch create -am "<commit message>" (gt bc -am ...)
git checkout -b <branch_name> && git add . && git commit -m "<commit message>"
Creating some changes, staging those changes, creating a new branch and committing those changes to the new branch is way too much work. Create your changes and run this single-line command to do all of that in one go.
gt commit create -m "<commit message>" (gt cc -m ...)
gt commit amend (gt ca)
To update an existing branch with new changes, you can
gt cc to create an entirely new commit on that branch or you can
gt ca to amend the existing commit on that branch. Some of our users follow a workflow that encourages a 1:1 relationship between commits and branches - if this is you,
gt ca is your friend.
See which files have been changed.
gt restore <file_name>
gt restore .
git checkout -- filename
On the same vein as
gt status, restore files to their original state if you accidentally made changes.
gt repo sync --restack (gt rs -r)
A quick command to pull changes from your trunk branch and subsequently restack upstack changes. Same as
gt repo sync && gt stack restack under the hood.
gt submit stack (gt ss)
Submit your changes across all PRs on a stack.
gt submit stack --no-edit --publish (gt ss -np)
Submit your PRs, but skip the PR editing flow (especially if you prefer to edit PR descriptions/titles etc.) on the Graphite dashboard.
Collaborating on a stack
Graphite is ultimately a collaboration tool - there are a suite of commands we use daily to see teammates code and communicate changes.
gt downstack get <branch_name> (gt dsg ...)
git checkout <branch_name>
A popular command for getting a stack locally that's been created/manipulated by someone else. Oftentimes followed up with
gt bdl to delete irrelevant branches locally.
gt branch checkout (gt bco)
git checkout branch <branch_name>
Often used when wanting to check out a singular branch for collaboration OR personal use.
Stack navigation/manipulation commands
These are commands that we're using to move up and down the stack and to restack branches if necessary.
gt branch [up|down] (gt b [up|down])
Quickly move up and down a stack of branches. By default, takes a
step argument of 1, but can add a
step value (ex.
gt branch up 2) to skip a certain number of branches.
gt branch [bottom|top] (gt [bb|bt])
Quickly move all the way down (
bb) or all the way up (
bt) a stack.
Troubleshooting the CLI
We all run into situations where we need to start from scratch - here are a few commands we frequent on the rare occasion that we run into a messed up state on the CLI.
gt repo init --reset && gt dev cache --clear
This combination of commands resets Graphite repo metadata and clears the cache.