Graphite cheatsheet

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.

Compare to: git log

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.

Compare to: 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.

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.

Compare to: git status

See which files have been changed.

Compare to: git checkout -- filename

On the same vein as gt status, restore files to their original state if you accidentally made changes.

Compare to: git pull

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.

Compare to: git push

Submit your changes across all PRs on a stack.

Compare to: git push

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.

Compare to: 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.

Compare to: 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.

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.

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.

This combination of commands resets Graphite repo metadata and clears the cache.