Prerequisites
To create a stack of branches with the Graphite CLI, make sure you’ve:- Installed and configured the CLI
- Authenticated with GitHub
-
Initialized
gt
in a repo of your choice
Create your first branch with the CLI
If you’re familiar with thegit
workflow, creating a branch and staging/committing changes shouldn’t be new to you. While using a git
-style workflow to create branches in Graphite still works, we strongly recommend that you follow the Graphite workflow when creating and editing branches:
- Add your changes directly on top of an existing branch. **DON’T **create an empty branch before doing so (we’ll explain further down).
-
Stage these changes using
gt add -a
to stage all of your files, orgt add <FILENAME>
to stage individual files -
Create a new branch with these changes using
gt create ...
git
workflow, you would instead break up into multiple branches in Graphite (typically with one commit on each branch).
Different ways to create a branch
Here are a few ways to create a branch containing a single commit usinggt create
:
Terminal
Configure a branch prefix
When usinggt create
, you can decide whether to pass in a branch name. A branch name is auto-generated from your commit message if a branch name isn’t provided.
You can configure a prefix for gt create
to add to all of your auto-generated branch names. See Configure the CLI for more details.
Stack more branches on top
Once you’ve created a branch with your first set of changes, you can continue to build your stack by issuing moregt create
commands as you work.
Terminal
Create a stack from an existing branch
If you have a large branch that you want to split up into a stack of smaller branches, you can use thegt split
command. Learn more about splitting a branch.