Run parallel sessions with worktrees changedworktrees
Upstream edited this page at 28 Oct 2026 19:53 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 28 Oct 2026 20:07 UTC.
Upstream edited
Recorded here
Lines+15added
Lines−1removed
From line
210
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits40to this page, all time
### `Can only use --worktree in a git repository` ### The worktree directory `belongs to a different repository`
The whole hunk
from line 210, old and new numbered
/
from line 210
210210
211211### Reuse a worktree name
212212
213Passing `--worktree` a name whose directory already exists opens that existing worktree instead of creating a new one.
213If 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).
214214
215215With 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:
216216
from line 348
348348### Worktree creation fails in a partial clone
349349
350350An error containing `This repository is a partial clone` means Claude Code couldn't fetch every git object the worktree's starting commit needs. Take the step in the message's sentence ending in `try again`. Then retry from the shell where you took it: run `claude --worktree`, or start `claude` there and ask again.
351
352### `Can only use --worktree in a git repository`
353
354This error means you passed `--worktree` in a directory that isn't a git checkout, and no [`WorktreeCreate` hook](#non-git-version-control) is active.
355
356* In a folder with no version control, run `git init` there, create a first commit, then retry.
357* In a checkout of another version control system, set up the hook the message suggests.
358* To work in the directory directly, start Claude without `--worktree`.
359
360### The worktree directory `belongs to a different repository`
361
362The errors `belongs to a different repository` and `is a leftover worktree` both mean git ties the directory for the worktree name you passed to another location. This can happen after you copy or move a project.
363
364Pass a different worktree name. If the directory has no work to keep and you didn't copy or move a project, you can remove it and retry the same name. After a copy or move, that retry can fail with `is already checked out elsewhere in this repository`, so use a different name.
351365
352366### Claude Code refuses to use a worktree
353367
No line in this hunk matches that.