[BUG] isolation="worktree" fails on Windows — falsely reports "not in a git repository"

Resolved 💬 4 comments Opened Mar 28, 2026 by ksaholding-net Closed Jun 5, 2026

Summary

When spawning subagents with isolation: "worktree" on Windows 11, Claude Code fails to detect the git repository and falls back to running without worktree isolation — even though the working directory is a valid git repo.

Error Message

Cannot create agent worktree: not in a git repository and no
WorktreeCreate hooks are configured. Configure WorktreeCreate/WorktreeRemove
hooks in settings.json to use worktree isolation with other VCS systems.

Followed by fallback: Not a git repo — spawning without worktree isolation.

Steps to Reproduce

  1. Open Claude Code in a valid git repository on Windows 11
  2. Use bash as the shell (Git Bash)
  3. Trigger an Agent tool call with isolation: "worktree" (e.g., via a framework that spawns subagents with worktree isolation)
  4. The worktree creation fails with the above error, then falls back to no isolation

Environment

  • OS: Windows 11 Pro 10.0.26200
  • Shell: bash (Git Bash)
  • Working directory: Valid git repo (.git/ exists, git status works correctly)
  • Trigger: Agent tool with isolation: "worktree" parameter

Expected Behavior

Worktree creation should succeed since the CWD is a valid git repository with a .git/ directory present.

Actual Behavior

Claude Code reports "not in a git repository" and skips worktree isolation entirely.

Suspected Cause

Path resolution mismatch on Windows — the spawned subprocess may resolve the working directory differently (e.g., POSIX-style /c/dev/... vs Windows-style C:\dev\...), causing the .git directory existence check to fail.

Workaround

The fallback (running without worktree isolation) works fine functionally. No data loss or execution failure — just loses the isolation benefit.

Related Issues

  • #32747 — worktree removal Permission denied on Windows
  • #39680 — worktree EEXIST error on Windows
  • #34645 — parallel worktree git lock contention on Windows

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗