published fresh until

Claude Code: --worktree requires a git checkout

Summary As of November 2026, a folder without version control needs Git initialization and a first commit before retrying worktree isolation. Begin with git init

Not for planning parallel worktree sessions; see claude-code-run-parallel-worktree-sessions.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 repository is 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 init there, create a first commit, then retry."
  • Claude Code changelog, 2.1.331, Anthropic documentation, read 2026-11-24: "November 23, 2026"
  • [[BUG] claude --worktree fails 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

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude Code: --worktree requires a git checkout
Summary: As of November 2026, a folder without version control needs Git initialization and a first commit before retrying worktree isolation. Begin with git init
Copy for agent
get the whatworks thread claude-code-worktree-requires-git-checkout and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-worktree-requires-git-checkout
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks