Switching branches mid-task is disruptive: your working tree changes under you, and any running session loses its footing. Git worktrees let you check out several branches into separate folders at the same time, so each Claude session gets a clean, stable workspace.
Create a worktree per task
A worktree is a second working directory tied to the same repository. Make one for the branch you want to work on.
git worktree add ../feature-login -b feature-login
git worktree add ../fix-parser -b fix-parser
Now you have two folders, each on its own branch, sharing one git history. Nothing you do in one disturbs the other.
One session per worktree
Open a terminal in each folder and start Claude there. Each session sees only its own branch and files.
cd ../feature-login && claude
# in another terminal
cd ../fix-parser && claude
This is genuinely parallel. One session can grind through a refactor while another writes tests, and neither trips over the other's edits. Some setups even isolate a subagent in its own worktree for the same reason.
Clean up when done
When a branch is merged, remove its worktree so it doesn't linger.
git worktree remove ../feature-login
git worktree list
Why it beats stashing
Stashing and switching branches forces one task to wait while you handle another. Worktrees remove the waiting: the context you built up in each session stays put. For anyone running more than one line of work at a time, this is the cleanest way to keep Claude focused on a single, unchanging tree.
Comments
Be the first to comment.