Creating a stack
Graphite's CLI makes it easy to stack dependent branches on top of each other.

Creating your first branch

Note that unlike a standard git workflow - where you create a new branch before working on your feature - with gt we recommend the following:
  1. 1.
    Start by building your feature on an existing branch
  2. 2.
    Stage your changes (gt add -A)
  3. 3.
    Create a new branch with those changes (gt branch create)
1
gt branch checkout main
2
3
# * build feature part 1 *
4
5
# create a new branch off of main with your changes and add a commit
6
gt add -A # add all unstaged change (same syntax as git add)
7
gt branch create -m "part 1" # -> creates a commit with message "part 1" on a branch named "05-04-part_1" (inferred from the date and your commit message)
8
9
# alternatively, you can combine the last 2 commands into a single line:
10
gt branch create -a -m "part 1"
Copied!
Because you didn't pass in a branch name in the above example, gt branch create auto-generated a branch name from your commit message. You can configure a prefix for gt branch create to add to all of your auto-generated branch names using gt user branch-prefix - see the CLI command reference for more details.

Creating a branch without staged changes

Graphite also supports creating your branch before starting to code! In order for Graphite's branch metadata to correctly track dependencies, Graphite will create an empty commit if you create a branch without staged changes, which you are free to either amend or commit on top of with the commit-level commands. If you prefer not to amend commits, you can avoid an empty commit in your history with squash-and-merge.

Stack more branches on top

1
# * build feature part 2 *
2
3
# create a new branch on your stack
4
gt branch create -a -m "part 2"
5
6
# * build feature part 3 *
7
8
# create another new branch on your stack
9
gt branch create -a -m "part 3"
Copied!
Now that you've created a stack, you can use Graphite's CLI to easily visualize it in your terminal.