Guide
Claude Code worktrees: one session, one branch, no collisions
Two Claude Code sessions in one folder edit the same files and trip over each other. A git worktree gives each session its own checkout on its own branch, sharing one repository. Claude Code has this built in: one flag, and it makes the worktree, starts in it and cleans up after.
Updated
Start a session in a worktree
claude --worktree feature-auth-w is the short form. Claude Code creates .claude/worktrees/feature-auth/ at the root of the repository, on a new branch worktree-feature-auth, and starts there. Leave out the name, and it makes one up, like bright-running-fox.
Open a second terminal and start another:
claude -w fix-checkoutNow two sessions work side by side, and neither sees the other’s uncommitted changes. Two things to do once:
- add
.claude/worktrees/to.gitignore, so the worktrees stay out ofgit status; - make at least one commit: a worktree needs something to branch from.
Sources: Claude Code documentation: Worktrees, Claude Code documentation: Common workflows: run parallel sessions with worktrees
Which branch it starts from
The setting worktree.baseRef decides:
| Value | The worktree starts from |
|---|---|
"fresh" (default) | the remote’s default branch, such as origin/main |
"head" | what you have checked out now, local commits included |
It can’t be a branch name. To work on a pull request, pass its number or address instead: claude -w "#1234". Using tmux? claude -w feature-auth --tmux opens the worktree in a tmux session of its own.
Sources: Claude Code documentation: Worktrees, Claude Code documentation: CLI reference
Mid-session and for subagents
- Ask Claude to “work in a worktree”, and it moves the session into one.
- A subagent gets a worktree of its own with
isolation: worktreein its frontmatter.
While a session is in a worktree, Claude Code blocks edits and commands aimed at the main checkout, git -C and GIT_DIR tricks included.
Sources: Claude Code documentation
Cleaning up
| How you ran it | What happens at the end |
|---|---|
| Interactive, nothing changed | the worktree and its branch are removed |
| Interactive, with changes or commits | Claude asks: keep or remove |
claude -p | nothing: remove it yourself |
For the last case:
git worktree list
git worktree remove .claude/worktrees/feature-authIf git says the worktree is locked, run git worktree unlock on it first.
Sources: Claude Code documentation, Git documentation
How many at once
As many as your computer and your plan allow. Every session spends the same Claude plan: three sessions use the 5-hour window three times as fast. How the limits work.
A branch per job, without a terminal
Worktrees solve the files. You still keep a terminal per session, watch each one, and clean up after -p runs.
DuoWave does the same job from a web panel. You write the task and press Start; DuoWave makes a copy of your folder for that job, on its own branch duowave/…, and starts Claude Code in it. When the job ends, its branch is in your folder. Your checked-out branch and your files never change.
The copy is not a git worktree but a separate local clone, git clone --local, made by hard links, so it is quick. Its git settings can’t touch your folder’s. It keeps your folder’s remotes, but pushing is up to you: git push works only if you add it to the folder’s allowed commands. DuoWave itself never pushes.
What else each job gets: a live journal of what Claude reads, changes and runs; preparation commands for a fresh copy (npm ci) and checks after the agent (npm test); a note added on the way; a wait instead of a failure when your plan hits its limit; a deal in Spending. One job in work folders runs at a time; the next waits in the queue. Claude Code with DuoWave.
Sources: DuoWave, release 0.15.0
Questions
Does Claude Code support git worktrees?
Yes: claude --worktree <name>, or -w. It creates the worktree under .claude/worktrees/ on a branch worktree-<name>.
Where do Claude Code worktrees go?
Into .claude/worktrees/<name>/ at the root of the repository.
Does Claude Code delete the worktree?
In an interactive session with no changes, yes, branch and all. With changes, it asks. After claude -p, it leaves the worktree for you to remove.
Can I choose the base branch?
Between the remote’s default branch ("fresh") and your current HEAD ("head"), with worktree.baseRef. Or start from a pull request: claude -w "#1234".
Do parallel sessions share my usage limit?
Yes. Every session spends the same plan.
Sources
Checked on 17 November 2026.
- Claude Code documentation: Worktrees
- Claude Code documentation: Common workflows: run parallel sessions with worktrees
- Claude Code documentation: CLI reference — `--worktree`, `--tmux`
- Git documentation: git-worktree
- DuoWave, release 0.15.0: changelog — Works in work folders; Spending: dollars and tokens by model
DuoWave
One small program between your things and any AI
DuoWave is a free, open-source AI assistant. Say what you need — it builds small apps, automates your routine and reports back when it's done.
DuoWave is an independent project. It is not affiliated with or endorsed by any speaker maker or AI company. Product names belong to their owners.