Updating mid-stack branches
Stacked changes aren't just about adding more branches on top - sometimes you want to go back and change something mid-stack. Graphite makes it easy to update a mid-stack branch, and conveniently restacks upstack branches automatically.
After updating branches in your stack locally, you can run gt stack submit
again to push the changes to remote.
Adding commits
Let's say you receive some comments in code review that you want to address with a new commit before landing a branch in the middle of your stack - here's how you'd do this with gt
:
# address review comments with a new commitgt branch checkout my_stack_level_1gt commit create -a -m "my fourth commit" # -> automatically restacks both upstack branches
Amending commits
If you prefer to just amend a previous commit, this is just as easy with gt
:
# address review comments by amending a commitgt branch checkout my_stack_level_1gt commit amend -a -m "my updated commit" # -> automatically restacks both upstack branches
Resolving rebase conflicts
If gt commit create
or gt commit amend
encounter any conflicts as they recursively restack your branches, you'll be prompted to resolve your conflicts before continuing:
Hit conflict restacking pp--06-14-part_3 on pp--06-14-part_2.Unmerged files:1You are here:◉ pp--06-14-part_3 (needs restack)◯ pp--06-14-part_2◯ mainTo fix and continue your previous Graphite command:(1) resolve the listed merge conflicts(2) mark them as resolved with gt add .(3) run gt continue to continue executing your previous Graphite command
Note that Graphite does not currently provide its own abort command — git rebase --abort
is safe to use to abort a single rebase in progress, but will not undo prior restack operations if your command already completed them.