Prerequisites
To visualize a stack of branches with the Graphite CLI, make sure you’ve:- Installed and configured the CLI
- Authenticated with GitHub
-
Initialized
gtin a repository of your choice - Created or tracked a branch or stack of branches
Visualize a stack of branches
Using a stacked changes workflow allows you to easily visualize the dependencies between all of your branches, pull down other teammate’s branches to collaborate, and even view multiple stacks of changes at once. Graphite provides three ways to visualize your stack, ranging from extremely detailed with lots of metadata, to very simple and to-the-point.gt log
This is one of the most commonly used log commands to view a stack of branches:
terminal
gt log short
The short subcommand allows you to quickly navigate and switch between branches in a stack.
terminal
gt log long
+The output of log long shows the current git history instead of the Graphite view:
terminal
Optional flags
log and log short both support a series of optional flags. Since log long is just a shortcut for the aforementioned git command, it doesn’t have the same customizability.
-
gt log --stack: shows the direct descendants and ancestors of the current PR. By default the commands show all branches currently tracked with Graphite. -
gt log --steps <n>: implies--stackbut only shows n levels of descendants and ancestors. -
gt log --reverse: displays the log withtrunk(also known asmain) at the top instead of the bottom. Useful for larger stacks to keep their tips near the bottom of the output.
More about your branches
Once you’ve submitted your branches with Graphite,gt log also includes a link to the PR page and some details about its status.
You can view information for one branch at a time with gt branch info. By default this shows the children and parents of the branch, as well as the descriptions for each commit in the branch. There are also --description and --patch options to see the PR description (if one exists) and the changesets of each commit.