功能

Worktrees

Worktree session 在 repository 的隔离副本中运行,因此并行 agents 无法覆盖彼此的文件。Worktrees 需要 git repository,位于 ~/.grok/worktrees/<repo>/<name> 下,并从当前 HEAD 开始,其中包括未提交的更改。当父 Agent 委派并行工作时,Subagents 也可以请求 worktree 隔离。

启动 Worktree

Bash

grok -w
grok --worktree=feat "refactor module X" # = keeps the prompt out of the name
grok -w --ref main "fix the flaky test"  # clean checkout of the ref
grok -w -r <session-id>                  # resume in a fresh worktree

在 TUI 中:/fork --worktree 将当前 session fork 到 worktree;欢迎界面中的 Ctrl+W 打开 New Worktree dialog;Ctrl+WAgent Dashboard 中将新 agents 分发到 worktrees。/new/fork 是否提供 worktree 可进行配置,请参阅 TOML Values

Worktree 是真实的 git checkout,在 base commit 上处于 detached 状态;使用普通 git 命令合入更改。

清理

Worktrees 会一直保留到你主动移除它们:结束或删除 session 后,其 worktree 仍会保留;gc 只会在你调用时运行。

命令作用
grok worktree list列出已跟踪的 worktrees
grok worktree show <id>显示某个 worktree 的详情
grok worktree rm <ids...>移除 worktrees(使用 --dry-run 预览)
grok worktree gc移除目录已不存在的条目;--max-age 7d 还会清理未被运行中 process 使用的闲置 worktrees