anthropics / anthropics/claude-code

Session's declared worktree path sometimes not populated by git worktree add — falls through to shared main checkout

Offen
#91,349 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area:core bug
Vorherrschende Sprache
Python
Sterne
145k
Forks
23.1k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Investigating a session that was given a `.claude/worktrees/` path in its system prompt as its "Worktree path", but the directory was completely empty (no `.git`, no files) even though the session had already done real work (reading files, editing, committing, pushing a branch, opening/merging a PR).

Because `git` walks up parent directories looking for `.git` when none exists in the cwd, every git command run with that empty directory as cwd silently resolved to and operated on the shared main repo checkout instead of an isolated worktree. The session's own commits/push/PR were still valid (they hit the real `.git` and remote), so no work was lost in that instance — but the isolation the harness presumably intended was silently absent for the whole session, and a concurrent session using the same shared checkout could have had its own in-progress branch/checkout state stomped on.

Broader check across the same repo (read-only) found this is not a one-off: under `.claude/worktrees/` there were 12 directories total, but `git worktree list` only registered 6 of them as real, populated git worktrees. The other 6 were empty shells not registered in `git worktree list` at all, with folder mtimes spanning at least two days and clearly many separate sessions (not one bad run). One of the six was later cleaned up automatically (removed entirely) between checks; the other five are still sitting there empty and unregistered.

This suggests the session-provisioning step creates/declares a worktree folder and path, but the corresponding `git worktree add` that should populate and register it doesn't always run (or fails silently, or races) — leaving the session pointed at a path that git treats as no worktree at all, with a silent fallback to the shared checkout rather than any error.

Reported as a repo-external / harness-level issue since there's no application code path to fix; happy to share more detail on the repo layout if useful (kept generic here since the actual repo is private).

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Begin with the harness-level session-provisioning path that creates `.claude/worktrees/`, then compare the expected `git worktree add` step with `git worktree list` for empty directories. Done means each declared path is populated and registered, while any failed or raced provisioning attempt reports an error instead of falling back to the shared checkout.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
git
Bereich
cli, devtools
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Aktiv
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.