Fork a Grok Build session
Fork a Grok Build session
/fork branches the current session into a peer that starts from a copy of the conversation. Official: Sessions, Worktrees.
Fork in the TUI
- Open the session you want to branch.
- Run
/fork(optional directive after the command). - Pass
--worktreewhen the fork should run in an isolated git checkout, or--no-worktreeto stay in the same tree. - Continue in the new peer session; the original session stays where you left it.
Fork when resuming from the CLI
grok -r <session-id> --fork-session
--fork-session creates a new session id from the resumed history instead of continuing the same id. Combine with -w / --worktree when parallel agents must not overwrite each other’s files.
Worktrees
A worktree fork lives under ~/.grok/worktrees/ and starts from your current HEAD (including uncommitted changes unless you pass --ref). Land changes with ordinary git. Housekeeping: grok worktree list, show, rm, and gc — see Use Grok Build worktrees.
Pitfalls
- Forking without a worktree when two agents edit the same paths.
- Expecting
/forkto undo file edits the way/rewinddoes — fork copies conversation context; rewind restores snapshots.