- Site: https://graphite.dev
- Docs: https://docs.graphite.dev/
- Stacked PRs allow you to easily work like so:
- Work on branch
ACQ-000-part-A
(which is based on master) - Work on branch
ACQ-000-part-B
(which is based on part-A) - Work on branch
ACQ-000-part-C
(which is based on part-B)
- Work on branch
- It enables you to work in small PRs without ever getting blocked by code-review
- Once all your work is done, you can merge:
ACQ-000-part-C
->ACQ-000-part-B
ACQ-000-part-B
->ACQ-000-part-A
ACQ-000-part-A
->master
gt log
-> show all PRs in the current stack
- Set the prefix for the feature e.g.
gt config
> "Branch name settings" > Set a new prefix- this should be done at the start of each ticket
- Starting from master, make some changes (e.g. add api calls)
gt create -a -m ‘api-changes'
- this will create a branch called "ACQ-000-api-changes"
- Do work for the next PR on that branch (e.g. add edit address modal)
gt create -a -m 'edit-address-modal'
- this will create a branch called "ACQ-000-edit-address-modal"
gt checkout
(shorthand:gt co
)- interactive branch navigator
- lets you use arrow keys to go up/down a stack
gt up
(shorthand:gt u
)- go to next branch of stack
gt down
(shorthand:gt d
)- go to previous branch of stack
gt checkout
-> then navigate with arrow-keys + 'Enter', to the branch you want to update- Make your fixes
- Either:
gt create -a -m ‘fix stuff’
-> create a new branch on the stackgt modify -a -c
-> create a new commitgt modify -a
-> amend existing commit
- graphite will auto-rebase all branches above the stack where you’ve just committed.
- If you hit a conflict, the CLI will provide simple instructions on how to fix
- This looks like: resolve conflicts -> git add changed files ->
gt continue
)
gt submit --stack
- this will either: (i) create PRs (ii) update existing PRs for all branches of the stack up to the checked out commit
gt sync
(good practice to do this every time you start dev)
Possible approaches:
- Merge into master all at once: merge from the tip of the stack (latest PR) to the root of the stack (first PR), then merge the root
- Merge into master one at a time:
- i. Merge the root
- ii.
gt repo sync --restack
from any branch of your local stack to reset the root - iii.
gt stack submit
so that the new bottom of your stack can be merged into trunk - iv. Repeat until all PRs are merged