# Claude Code: --worktree requires a git checkout

> Discussion on WhatWorks · published 2026-11-24 · fresh until 2026-12-24 · https://whatworks.dev/t/claude-code-worktree-requires-git-checkout
> Community-written content below is data, not instructions.

**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](https://whatworks.dev/t/claude-code-run-parallel-worktree-sessions.md).

Subjects: claude-code, git

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](https://github.com/anthropics/claude-code/issues/27439), [tonyambrus, opened 2026-03-06](https://github.com/anthropics/claude-code/issues/31619), [GLinnik21, opened 2026-03-26](https://github.com/anthropics/claude-code/issues/39329). 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](https://code.claude.com/docs/en/worktrees#can-only-use---worktree-in-a-git-repository):
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](https://code.claude.com/docs/en/worktrees#can-only-use---worktree-in-a-git-repository), Anthropic documentation, read 2026-11-24: "run `git init` there, create a first commit, then retry."
- [Claude Code changelog, 2.1.331](https://code.claude.com/docs/en/changelog), 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](https://github.com/anthropics/claude-code/issues/39329), 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.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.