Getting remote branches with gt get
gt get
allows you to pull your coworker’s stacks from remote into your local repository to see their changes on your own machine or as a starting point for collaboration.
For example, coworker A creates and submits their branch:
Terminal
Terminal
my_branch
depends on (starting from the bottom of the stack). If any of the branches already exist locally and differ from the remote version, Graphite will ask to either overwrite your local changes or rebase them on top of the remote version.
gt get
is also the recommended workflow for developers who work on more than one machine:submit draft PRs for your stack on one machine with gt submit
and then use gt get
from the other device.Building together
To build on top of your coworker’s changes rungt get
on the branch you want to build on top of, make your changes, and run gt create
, exactly the same way you would to create a stack on-top of your own branch. For example, to stack some analytics changes on-top of your coworker’s frontend changes:
Terminal
gt submit
to submit your new branches to Graphite.
Staying in sync
As you and your teammates push to your shared stack, you should both periodically run:gt sync
to pull down any new changes the other has made to existing branchesgt get
for each net new branch the other has madegt submit
to push up changes
gt sync
restacks by default to keep your branches up-to-date with the latest remote. If your trunk branch has been updated, you may be prompted to resubmit changes (including rebase-only changes). If you’d like to sync without restacking, run gt sync --no-restack
.Getting a partial stack
By default,gt get
will sync the full stack. If you’d like to pull down just part of a stack, you can run gt get --downstack
to sync just downstack branches.
Safely building on a coworkers stack
Ingt
version 1.7.0, the concept of “frozen” branches was introduced. A “frozen” branch will still be kept up to date with remote changes when it is synced, but will block local changes being made to it. This allows you to pull down a coworker’s branch and stack on top of it without worrying about accidentally making edits to their changes.
- If
gt get
is pulling down a new branch, it will mark that branch as “frozen” by default (you can use the--unfrozen
flag if you want to get the branch in an editable state). - You can also use
gt freeze
andgt unfreeze
to update the “frozen” status of a branch. - You can see if a branch is frozen or not with the
gt info
orgt log
command.
Advanced: collaborating on non-Graphite branches
We strongly recommend that coworkers who wish to collaborate on a branch both usegt
to ensure that the dependencies are managed and synced correctly as you work together.
Only branches that your coworkers have submitted with gt
can be synced down to your local environment, as we rely on the Graphite submission to keep track of the dependency tree.
If you want to stack on top of your non-Graphite-using coworkers’ branches, the best way to do this is git pull
and gt track
. However, Graphite will rebase these branches on a gt sync
, just like branches you created.