Mutation 前先 inventory
先用 grok worktree list --json;多專案時依 repo 縮小。用 worktree show + exact ID/path 檢查 candidate。
在 worktree 內查 Git status、untracked files、branch、HEAD、unpushed commits;tracking record 不能證明可丟棄。
grok worktree list --json
grok worktree show ID_OR_PATH 預覽 remove 與 GC
grok worktree rm 可接多個 IDs 並支援 --dry-run;gc 也有 --dry-run/max-age。先 preview,mutation 前再 resolve candidates。
Dirty/unpushed work 未 review/preserve 前不要 --force;age 不是 obsolete evidence。
- 使用 exact IDs,不用 broad globs。
- 需要 retention 時先 diff/commit。
- Cleanup 後 re-list 驗證。
Database 分開處理
worktree db stats/path 檢查 tracking metadata;db rebuild 從 filesystem 重建 database,改的是 local index,不是 Git history。
Tracking 錯誤才 rebuild,不把它當 Git cleanup;review scan roots。