Learn how to work on shared collaborative stacks with other Graphite users. Stacking doesn’t have to be single-player, and it’s a great way to collaborate with teammates on a project or feature! This page talks about how to fetch remote stacks, stack on top of your co-worker’s PRs, and submit your own changes when working with others.
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:
gt create my_branch -m "My changes"gt submit
Then, coworker B pulls the branch to their machine:
gt get my_branch
This syncs all branches that 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.
Tip
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 run gt 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:
gt get "my-coworkers-frontend-changes"touch analytics.jsgt create -m "add-analytics"
Lastly, when you're ready to, just run 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
If you encounter any conflicts during restacking, Graphite will drop you into the same conflict resolution flow that you are already familiar with from both Graphite and git.
Note
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.
Advanced: collaborating on non-Graphite branches
We strongly recommend that coworkers who wish to collaborate on a branch both use gt
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 branch track
.