my-git

Worktree for AI Agents

English 中文

git worktree is suitable for isolating multiple AI tasks into different directories, reducing cross-contamination of workspaces.

Suitable Scenarios

Basic Commands

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

Claude Code Scenarios

Claude Code officially supports creating isolated sessions via --worktree:

claude --worktree feature-auth
claude --worktree bugfix-payment-timeout

These types of automatic worktrees are suitable for parallel exploration, but you should still return to the Git perspective to check before merging:

git worktree list
git status
git diff --stat

Extended Reading