Git Worktrees & Parallel Workstreams
- What a git worktree is — one repo, multiple working directories, each on its own branch
- The exact problem it solves: stopping parallel Claude sessions from colliding on the same files
- The four commands to add, list, and remove worktrees
- When the technique earns its keep — and the three pitfalls that bite at merge-time
- How worktrees compose with subagents: parallelism across sessions vs within one
A git worktree lets one repository have multiple working directories, each checked out to a different branch. Pair that with Claude Code and you can run several sessions in parallel on the same project — each editing its own files, with no collisions.
The problem it solves
If two Claude sessions edit the same working directory at once, they trip over each other's changes. Worktrees give each session its own directory and branch, so parallel work stays isolated until you merge.
The basics
Four commands carry the whole workflow: add a worktree (new dir + new branch), list what exists, and remove one when you're done.
- From your repo, git worktree add ../app-feature-a -b feat-a creates a new directory AND a new branch in one shot.
- git worktree add ../app-fix-123 -b fix-123 — a second isolated dir/branch, side by side with the first.
- git worktree list shows every working directory and the branch it's on.
- git worktree remove ../app-feature-a tears down a worktree so stale dirs don't accumulate.
The four-command workflow
# from your repo git worktree add ../app-feature-a -b feat-a # new dir + new branch git worktree add ../app-fix-123 -b fix-123 git worktree list # when done with one: git worktree remove ../app-feature-a
Open a Claude Code session in each worktree directory and let them work independently.
When it's worth it
- Parallel features/fixes you want to progress at once.
- A long task running in one worktree while you keep working in another.
- Risky experiments isolated from your main checkout.
Pitfalls
- Watch the merge-back: branches will eventually merge — conflicts surface then, not during. Keep worktrees focused and short-lived.
- Don't run stateful, shared resources (one dev DB, one port) from two worktrees without separating them.
- Clean up with git worktree remove so stale dirs don't accumulate.
Worktrees vs subagents
Two different axes of parallelism — they don't compete, they stack.
| What it parallelizes | Isolation | |
|---|---|---|
| Subagents | Work within one session (delegation) | Isolated context |
| Worktrees | Work across sessions on disk | Isolated branches/files |
They compose well: a session in a worktree can itself spawn subagents.
- Use a worktree when you need two Claude sessions touching the same repo at once; use a subagent when one session needs to offload a chunk of work into isolated context.
Check yourself
0/4- A git worktree = one repo, multiple working directories, each on its own branch — the basis for collision-free parallel Claude sessions.
- Two sessions on one working directory trip over each other; a worktree per session keeps files and branches isolated until you merge.
- git worktree add ../dir -b branch creates dir + branch; list shows them; remove cleans up.
- Worth it for parallel features/fixes, long-running tasks alongside other work, and isolated risky experiments.
- Beware the merge-back, don't share stateful resources (DB, port) across worktrees, and always clean up — and remember worktrees compose with subagents.