claude-code - 💡(How to fix) Fix [BUG] Background full checkout fails with not-a-git-repo when worktree mode is on for a repo with submodules [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#54904Fetched 2026-05-01 05:51:23
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×4

Error Message

Error Messages/Logs

[error] Git command failed: git -c core.longpaths=true checkout HEAD -- . :(exclude).claude [error] Sentry caught: { type: 'Error', [warn] [CCD] first-turn init failed after worktree creation; removing orphaned worktree

Code Example

From ~/Library/Logs/Claude/main.log (Claude Code 2.1.119, macOS):

[info] Created worktree "magical-elion-938fc4" at <repo>/.claude/worktrees/magical-elion-938fc4
[info] Starting local session local_998f40d7-... in <repo>/.claude/worktrees/magical-elion-938fc4
[error] Git command failed: git -c core.longpaths=true checkout HEAD -- . :(exclude).claude
        stderr: 'fatal: not a git repository: ../../../../../../.git/worktrees/magical-elion-938fc4/modules/ThirdParty/QCustomPlot/QCustomPlot
                 fatal: could not reset submodule index'
        cwd: '<repo>/.claude/worktrees/magical-elion-938fc4'
[error] Sentry caught: {
  eventId: '696d80420d94440fbe59b9d2d7564063',
  type: 'Error',
  value: 'Background full checkout failed: not-a-git-repo'
}
[warn] [CCD] first-turn init failed after worktree creation; removing orphaned worktree
[info] Removed worktree "magical-elion-938fc4"
RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

What's Wrong?

With "Use worktrees for sessions" enabled, opening a new session in a repo that has submodules fails before the session begins. The intro screen shows only:

Something went wrong Try sending your message again. If it keeps happening, share feedback so we can investigate. Background full checkout failed: not-a-git-repo

…and the typed prompt is returned to the input box.

What Should Happen?

The session should start

Error Messages/Logs

From ~/Library/Logs/Claude/main.log (Claude Code 2.1.119, macOS):

[info] Created worktree "magical-elion-938fc4" at <repo>/.claude/worktrees/magical-elion-938fc4
[info] Starting local session local_998f40d7-... in <repo>/.claude/worktrees/magical-elion-938fc4
[error] Git command failed: git -c core.longpaths=true checkout HEAD -- . :(exclude).claude
        stderr: 'fatal: not a git repository: ../../../../../../.git/worktrees/magical-elion-938fc4/modules/ThirdParty/QCustomPlot/QCustomPlot
                 fatal: could not reset submodule index'
        cwd: '<repo>/.claude/worktrees/magical-elion-938fc4'
[error] Sentry caught: {
  eventId: '696d80420d94440fbe59b9d2d7564063',
  type: 'Error',
  value: 'Background full checkout failed: not-a-git-repo'
}
[warn] [CCD] first-turn init failed after worktree creation; removing orphaned worktree
[info] Removed worktree "magical-elion-938fc4"

Steps to Reproduce

On macOS, in Claude Code 2.1.119, enable worktree mode. Open a repo containing at least one initialized submodule (a nested submodule is not required — a single top-level submodule reproduces it). Start a new session and submit any prompt. Observe the "Something went wrong" message; the session never begins.

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

Claude Code: 2.1.119

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

The issue can be fixed by properly handling submodules in the worktree creation process, possibly by initializing submodules before checking out the worktree.

Guidance

  • The error message "not a git repository" suggests that the issue is related to the submodule not being properly initialized in the worktree.
  • To verify, try manually initializing the submodule in the worktree using git submodule init and git submodule update before starting the session.
  • The git checkout command is failing due to the submodule not being a git repository, so modifying the checkout command to handle submodules correctly may be necessary.
  • Investigate the git -c core.longpaths=true checkout HEAD -- . :(exclude).claude command to see if it can be modified to properly handle submodules.

Example

No code example is provided as the issue is related to the internal workings of Claude Code and its interaction with git submodules.

Notes

The issue is specific to Claude Code version 2.1.119 and macOS, and it's not a regression, so the solution may need to be tailored to this specific version and platform.

Recommendation

Apply a workaround to properly handle submodules in the worktree creation process, as the issue is not fixed in the current version of Claude Code.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Background full checkout fails with not-a-git-repo when worktree mode is on for a repo with submodules [1 participants]