Full Byte Developer.

Separate Claude Code sessions with Git worktrees

Give parallel sessions separate files and branches while keeping their shared repository history.

Published · 1 source

Claude Code's worktree docs describe separate working folders and branches for parallel sessions [1]. Use one per task when two sessions would otherwise edit the same files.

Start the first isolated session

From your Git repository, use the documented example [1].

bash
claude --worktree feature-auth

You should see a worktree at .claude/worktrees/feature-auth on branch worktree-feature-auth [1]. In another terminal, use a different worktree name for the second task.

Keep generated worktrees out of status

Add this entry to your existing ignore file, preserving its other entries [1].

.gitignore
.claude/worktrees/

Copy only the ignored files you need

A fresh checkout lacks untracked environment files. The documented .worktreeinclude mechanism copies files only when they match its patterns and are also Git-ignored [1].

Warning: this creates additional copies of your local environment files. Include secrets only when the isolated task needs them.

.worktreeinclude
.env
.env.local

Review work before cleanup

The docs say Claude prompts about keeping or removing a worktree when it contains changes or commits. Keep any work you still need [1]. Separate worktrees isolate file edits; they are not a substitute for reviewing the combined changes before merging.

Keep this guide

By Full Byte Developer

Original posts: Instagram reel, TikTok video, YouTube Short, Facebook reel, Threads post

Filed under Claude Code, Dev tools

Sources

Next in this stack