CC-201c · Module 2
Git Worktrees
3 min read
Multiple Claude instances editing the same directory is a recipe for conflict. Instance A writes to src/auth.ts while Instance B reads it mid-write. Instance A commits while Instance B has uncommitted changes to the same files. The result is corrupted state, merge conflicts, and wasted work. Git worktrees solve this by giving each instance its own working directory with its own branch, while sharing the same Git repository and history.
The setup is a single command: git worktree add ../project-feature-auth feature/auth. This creates a new directory alongside your main project, checked out to the feature/auth branch. Launch a Claude Code instance in that directory. It has its own file tree, its own branch, and its own commit history — completely independent of your main working directory. When the feature is done, merge the branch normally. The worktree was just a workspace. The Git graph is unified.
# Create a worktree for a feature branch
git worktree add ../my-project-auth feature/auth
# Launch Claude Code in the worktree
cd ../my-project-auth && claude
# List active worktrees
git worktree list
# Remove a worktree when done (after merging)
git worktree remove ../my-project-auth