git worktree 适合把多个 AI 任务隔离到不同目录中,减少工作区互相污染。
git worktree add ../project-task-a -b ai/task-a
git worktree add ../project-task-b -b ai/task-b
git worktree list
git worktree remove ../project-task-a
.env、密钥、生产配置到 AI worktree.gitignoreClaude Code 官方支持通过 --worktree 创建隔离会话:
claude --worktree feature-auth
claude --worktree bugfix-payment-timeout
这类自动 worktree 适合并行探索,但合入前仍要回到 Git 视角检查:
git worktree list
git status
git diff --stat