Git worktrees let one repo run two Claude sessions side by side


Git worktrees let one repo run two Claude sessions side by side

The setup

You're mid-refactor with messy uncommitted changes. A bug on main needs a hotfix now. Stashing feels risky, switching branches loses your editor state, and two Claude sessions in the same folder will fight over the same files.

The jargon

The lesson

A git worktree is a second checkout of the same repo, in a different folder, on a different branch. Same .git history, separate working directory. Two Claude Code sessions, each in its own worktree, can edit different branches at the same time without stepping on each other.

Claude Code stores per-project state by working directory (under ~/.claude/projects/). To Claude, two worktrees are two projects. The sessions don't share history, don't see each other's tool calls, and don't compete for file locks.

How it works

# from inside your main repo
git worktree add ../myrepo-hotfix main

# new folder ../myrepo-hotfix now exists, checked out to main
# the original folder keeps your refactor branch and dirty changes

# list them
git worktree list

# clean up when done
git worktree remove ../myrepo-hotfix

The new folder is a full working tree, but .git is a small file pointing back to the original repo. No duplicated history. No extra disk for the object database.

Open a second terminal in the new folder, run claude, and you have a parallel session.

When to reach for it

When not to

Try it

Pick any repo on your machine. From inside it, in PowerShell:

$side = "../$((Get-Item .).Name)-side"
git worktree add $side main
cd $side
claude

Ask the new session something trivial — "summarise the README." Then cd back to the original folder and check that your old Claude session still has all its context. When you're done, from inside the main repo run git worktree remove $side.


Don't miss what's next. Subscribe to My Claude Daily Learning: