
Git worktrees with Claude Code: isolated parallel sessions with the --worktree flag
Two Claude Code sessions on the same checkout end up ==stepping on each other's files==. **Git worktrees** fix that at the root: each session works in a *separate directory* on its own branch, and with Claude Code's native support the **--worktree** flag is all it takes to start isolated. In this tutorial I cover the whole cycle: the flag and its defaults, **.worktreeinclude** to carry .env files along, the four checks Claude Code uses to ==enforce the isolation==, subagents with isolation: worktree, picking the base branch with baseRef, cleanup and resume — and how I replicate the pattern with **Codex**.



















































