What this thread does
Do first: in a folder with no version control, run git init, create a first commit, then retry the worktree launch.
Symptom
Claude Code prints Can only use --worktree in a git repository when starting with --worktree.
The same message appears in reports by zzJinux, opened 2026-02-21, tonyambrus, opened 2026-03-06, GLinnik21, opened 2026-03-26. These reports include differing environments and do not establish one cause for every case.
Cause
The guide says the launch directory is not a Git checkout and no WorktreeCreate hook is active. The issue reports include hook-related cases; they are evidence of the message, rather than instructions for fixing today's configuration.
Fix
Choose the route that fits the directory, as listed in this error's documentation: 1. No version control: run git init there, create a first commit, then retry. This section does not prescribe a commit command or initial file contents. 2. Another version control system: configure the WorktreeCreate hook suggested by the message, using the page's non-Git version control section. 3. No isolation needed: start Claude without --worktree to use the directory directly.
If it still fails
- A directory that
belongs to a different repositoryis a separate error on the same page and requires its own recovery. - This section does not assign a fix-release number. As of November 2026, the changelog's top entry is 2.1.331 (November 23, 2026).
Not for: planning parallel worktree sessions; see claude-code-run-parallel-worktree-sessions.
Sources
- Worktrees, Anthropic documentation, read 2026-11-24: "run
git initthere, create a first commit, then retry." - Claude Code changelog, 2.1.331, Anthropic documentation, read 2026-11-24: "November 23, 2026"
- [[BUG]
claude --worktreefails inside a bare repository](https://github.com/anthropics/claude-code/issues/27439), zzJinux, 2026-02-21; closed 2026-05-27 (state_reason: not_planned; closed_at: 2026-05-27T11:23:44Z) - [[BUG] --worktree CLI flag rejects non-git repos without checking for WorktreeCreate hooks](https://github.com/anthropics/claude-code/issues/31619), tonyambrus, 2026-03-06; closed 2026-03-10 (state_reason: duplicate; closed_at: 2026-03-10T09:18:36Z)
- --worktree fails in non-git repos even with WorktreeCreate/WorktreeRemove hooks configured, GLinnik21, 2026-03-26; closed 2026-03-26 (state_reason: duplicate; closed_at: 2026-03-26T12:32:28Z)
Checked
2026-11-24; read Worktrees, Claude Code changelog, 2.1.331 and the linked issue records; no command was run.
Started from a post by @Anthropic, packaged by the editor. Original post