Command-line interface
Graphite helps you throughout the whole development process — starting from the command line. Install the Graphite CLI to visualize, create, update, share, and submit stacks.
brew install withgraphite/tap/graphite
00.
How it works
The Graphite CLI fully integrates with Git. We simplify the process of trunk-based development and manage dependencies to enable stacking. Under the hood, we’re running Git to create branches, commits, and metadata, which means you can still use Git in your scripts, tooling, or whenever you feel like it.
01.
Creating your first stack
A stack is a series of dependent code changes. Graphite represents each change in a stack as a branch, which will be submitted as a pull request. To create a branch with Graphite, touch a file, and then run gt create
. To create a stack, do that again.
03.
Updating your stack
Once you’ve created your stack, you may need to iterate on branches that now have dependencies. Graphite makes it painless to update your stacked changes by rebasing any dependent branches for you when you make changes:
- 1. Check out the branch to update
- 2. Update your files
- 3. Amend the commit on your branch with
gt modify
(or create a new commit withgt modify --commit
). - 4. Graphite will automatically rebase any dependent branches for you
Like creating a stack, you can also use Git to update any PRs with dependencies. If you do so, you can run gt restack
to automatically rebase any dependent PRs.
Rebase conflicts
If you run into rebase conflicts during a restack, Graphite will drop you into the same conflict resolution state you might be familiar with from Git. Once you have resolved your conflicts, run gt continue
to intelligently apply that resolution to any dependent branches and continue with the rebase.
04.
Submitting your stack
To create or update GitHub pull requests (PRs) for your stack, run gt submit
. This will detect which branches need new PRs (and which ones have PRs which need to be updated), and ask you for a title and body for each PR, pulling in your preferred text editor and PR template.
Note: To submit, you need to have authenticated with Graphite.
05.
Syncing your repo
Once you merge a PR, you can use gt sync
to clean up the branch locally and update any dependent branches to depend on trunk (which now includes your changes).
06.
Advanced: Editing your stack
Use commands like gt move
and gt reorder
to change the order of branches in your stack. If you ever end up with a whole lot of code and want to split it into multiple branches, you can use gt split
.
07.
Advanced: Collaborating on your stack
If you ever need to checkout a teammate’s stack, use gt get
.