Desktop app worktree session fails on repos with an empty HEAD tree: "Background full checkout failed: other"

Status Fixed / completed
Reported on v2.1.222
Maintainer reply None cached
Activity 0 comments · opened Aug 13, 2026 · closed Aug 14, 2026

Environment

  • Claude Code (desktop app), Claude Code binary 2.1.222
  • macOS (Darwin 23.6.0)
  • Repo: a freshly created git repo whose only commit tracks zero files (empty tree, e.g. created with git commit --allow-empty -m "Initial commit")

Bug

Starting a new local session with the worktree option enabled fails with the dialog:

ブランチを切り替えられませんでした (Could not switch branch) Background full checkout failed: other

The session never starts, and the branch created for the session (claude/<name>-<hash>) is left behind in the base repo (the worktree itself is cleaned up, the branch is not).

Root cause

After creating the worktree, the app runs a full checkout:

git -c filter.lfs.smudge= -c filter.lfs.process= -c filter.lfs.required=false -c core.longpaths=true checkout HEAD -- . :(exclude).claude

When HEAD's tree contains no files, git exits 1:

error: pathspec '.' did not match any file(s) known to git
error: pathspec ':(exclude).claude' did not match any file(s) known to git

The app treats this as a fatal error ("Background full checkout failed: other"), first-turn init then fails, and the worktree is removed as orphaned.

Log excerpt from ~/Library/Logs/Claude/main.log:

2026-08-13 13:05:02 [info] [stageCheckout] Selective checkout done in 10ms (0 paths)
2026-08-13 13:05:02 [error] Git command failed: git -c filter.lfs.smudge= -c filter.lfs.process= -c filter.lfs.required=false -c core.longpaths=true checkout HEAD -- . :(exclude).claude { code: 1, spawnErrno: undefined, stderr: "error: pathspec '.' did not match any file(s) known to git\nerror: pathspec ':(exclude).claude' did not match any file(s) known to git\n", cwd: '.../.claude/worktrees/aws-weekly-updates-digest-610297' }
2026-08-13 13:05:02 [error] Sentry caught: { value: 'Background full checkout failed: other', ... }
2026-08-13 13:05:02 [warn] [CCD] first-turn init failed after worktree creation; removing orphaned worktree for local_5577466a-...

Steps to reproduce

  1. mkdir empty-repo && cd empty-repo && git init && git commit --allow-empty -m "Initial commit" (push to a remote if needed)
  2. Open the repo in the Claude Code desktop app
  3. Start a new session with the worktree checkbox enabled
  4. Error dialog appears; session fails to start; a stale claude/... branch remains

Workaround

Commit at least one file (e.g. a README) to the repo. After that, worktree sessions start normally.

Suggested fix

  • Skip the full checkout (or tolerate the "pathspec did not match" error) when HEAD's tree is empty, e.g. check git ls-tree -r HEAD --name-only first — the "Selective checkout done (0 paths)" stage already indicates there is nothing to check out.
  • Also clean up the session branch when first-turn init fails, not just the worktree directory.

🤖 Generated with Claude Code

View original on GitHub ↗