Run parallel sessions with worktrees changedworktrees
Nearest release: v2.1.334, published 5 hours before upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 2 Dec 2026 00:40 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 2 Dec 2026 01:07 UTC.
Upstream edited
Recorded here
Lines+5added
Lines−12removed
From line
233
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits57to this page, all time
The whole hunk
from line 233, old and new numbered
/
from line 233
233233
234234If a worktree with the name you pass to `--worktree` already exists, Claude Code opens it instead of creating a new one. If Claude Code stops with an error containing `belongs to a different repository` or `is a leftover worktree`, see [The worktree directory `belongs to a different repository`](#belongs-to-a-different-repository).
235235
236With the default `"fresh"` [base](#choose-the-base-branch), a reopened worktree resets to the repository's default branch instead of continuing at its old tip when all of the following hold:
236Claude Code reopens the worktree at its old tip or resets it to the repository's default branch. A reset needs the default `"fresh"` [base](#choose-the-base-branch) and all of these conditions:
237237
238238* The [sandbox](https://code.claude.com/docs/en/sandboxing.md#filesystem-isolation) isn't restricting file writes in your session, and neither the worktree's nor the main checkout's `.claude` settings files enable the sandbox.
239* The worktree has no uncommitted changes or untracked files.
239* The worktree has no uncommitted changes or untracked files that git reports. Gitignored files don't count.
240240* It is still on the branch Claude Code created for it.
241* It has no commits of its own, or its pull request or merge request was merged and its remote branch deleted.
241* It has no commits of its own, or its work was merged: its remote branch is deleted and its non-merge commits are already on the default branch.
242242
243Claude Code detects the merged case from git state alone: the remote branch the worktree pushed to no longer exists, and every commit in the worktree is already on the default branch.
244
245In every other case, Claude Code reopens the worktree at its old tip:
246
247* The worktree or session fails any of the conditions.
248* Claude Code can't verify the worktree's state.
249* `worktree.baseRef` is `"head"`.
250* The name is a pull request or merge request reference.
243Claude Code skips the reset in other cases too, such as when it can't verify the worktree's state or the name is a pull request or merge request reference.
251244
252245If you use the sandbox with the `"fresh"` base, run `git fetch origin`, then pass a new name to `--worktree` to start from the latest default branch.
253246
No line in this hunk matches that.