[BUG] EnterWorktree leaves a nested git submodule uninitialised (empty dir, no .git pointer) — 100% reproducible across fresh worktree names in one session

Open 💬 0 comments Opened Jul 2, 2026 by sterngold

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

EnterWorktree creates the parent git worktree correctly but leaves a nested git submodule uninitialised — an empty directory with no .git pointer. It happened on three consecutive brand-new worktree names in a row (100% reproducible in that session). Two worktrees created earlier the same session with different names initialised the same submodule correctly, so it isn't universal — but once it started it was a hard, repeatable wall.

The failure is silent and misleading: git log inside the empty submodule dir still resolves (it falls through to the parent repo's history), masking the problem, while git status and git submodule update --init <path> both fail.

What Should Happen?

EnterWorktree should return a worktree with the nested submodule fully checked out (its .git pointer present and files populated), OR fail loudly with a clear error — never silently hand back a worktree containing an empty, uninitialised submodule directory.

Error Messages/Logs

git submodule update --init <submodule-path>
fatal: destination path '<submodule-path>' already exists and is not an empty directory.

(git status / git submodule update fail inside the empty submodule dir; a harness-dropped .claude/.cc-writes marker made the target directory non-empty before git's clone step could run)

Steps to Reproduce

  1. A superproject that contains a nested git submodule.
  2. In a Claude Code session, call EnterWorktree with a brand-new worktree name.
  3. Inspect the submodule directory inside the new worktree — it is empty, with no .git pointer.
  4. Try to recover with git submodule update --init <path> — it fails with "destination path already exists and is not an empty directory" (the .claude/.cc-writes marker made it non-empty).
  5. Repeat with additional fresh worktree names — reproduced 3× in a row in the affected session.

Claude Model

Other

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.198 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

_No response_

View original on GitHub ↗