This guide describes Graphite’s multi-worktree behavior in
gt version 1.8.4 and above.gt sync, gt get, or gt restack need to be run separately from each relevant worktree. Use gt create --onto <branch> to create a new branch on top of a branch that is checked out elsewhere.
Understand the mental model
When you use Graphite across multiple Git worktrees, a few rules explain almost all of the behavior:- A Git branch can only be checked out in one worktree at a time.
- Graphite respects that rule and avoids mutating branches that are checked out in another worktree.
- If a command would need to rewrite or check out a branch in another worktree, Graphite exits with an informative error instead of changing that worktree behind your back.
-
gt undohistory is per-worktree, so undo in one worktree targets commands that were run from that same worktree. -
gt logshows which worktree a branch is checked out in when multiple worktrees are present.
Recommended workflow
- Avoid simultaneously having more than one worktree on the same stack when possible.
-
Use
gt logto confirm where branches are checked out before syncing, restacking, or undoing.- When you have more than one worktree open for the same repository,
gt logshows the worktree path next to branches that are checked out. - If you are not sure why a command will not touch a branch, run
gt logfirst. It is the fastest way to confirm where that branch is currently checked out.
- When you have more than one worktree open for the same repository,
-
Use
gt create --ontowhen you want to start a new branch on top of a branch that is already checked out in another worktree. -
If one stack spans multiple worktrees, run
gt syncorgt restackin each worktree as needed to sync or restack the entire stack.- For example, if one worktree has
feature-achecked out and another hasfeature-bchecked out on top of it, runninggt syncfrom thefeature-aworktree may still update localtrunkand updatefeature-a, but it does not updatefeature-bin the other worktree.
- For example, if one worktree has
- If Graphite tells you that a branch is checked out in another worktree, switch to that worktree or move that other worktree to a different branch before retrying.
Know when Graphite stops instead of crossing worktrees
-
gt modify --intostops if the target branch is checked out in another worktree. -
gt undoonly undoes commands that were run from the current worktree, and it stops if the undo would need to modify or check out a branch that is checked out elsewhere.