Navigate A Stack
Learn how to navigate stacked branches with the Graphite CLI.
Prerequisites
To navigate a stack of branches with the Graphite CLI, make sure you’ve:
-
Initialized
gt
in a repo of your choice -
Created or tracked a branch/stack of branches
gt log
You can use gt log
to view the current state of your repository:
Check out a branch
Branches in Graphite are just git
branches under the hood—you can check them out with native git
, but the easiest way is to use gt checkout
:
If you aren’t sure which branch you want to checkout, you can also use gt checkout
(or gt co
) in interactive mode:
Now, you can see in gt log short
you’re on part_1
as intended:
Move up and down a stack
Sometimes you want to move to the branch directly above or below the current branch in a stack. The gt up
, gt down
, gt top
, and gt bottom
commands help make this possible.
Since gt bottom
takes you to the bottom-most branch in your stack not including your trunk branch, you can use gt checkout --trunk/-t
, which always takes you to your trunk
branch (e.g. main
):
If you find yourself navigating a complex stack where there are multiple children of a particular branch, gt up
and gt top
will ask which child branch you’d like to checkout if there’s ever ambiguity.