Git worktrees of the same repo share the same project identity, causing cross-worktree path confusion
Status Closed — duplicate
Maintainer reply None cached
Activity 3 comments · opened Mar 5, 2026 · closed Mar 9, 2026
Description
When using multiple git worktrees for the same repository, Claude Code resolves all worktrees to the same project identity. This causes path confusion and memory/context bleeding between worktrees.
Reproduction steps
- Create multiple git worktrees from the same repo:
````
~/dev/code/backend/backend_main (main branch)
~/dev/code/backend/backend_skills (feature branch)
~/dev/code/backend/backend_feature (another feature branch)
- Start Claude Code from
backend_skillsworktree
- Observe the auto memory directory path in the system prompt:
```
/Users/<user>/.claude/projects/-Users-<user>-dev-code-backend-backend-main/memory/
backend-main
This points to , **not** backend_skills`.
Expected behavior
Each worktree should be treated as a separate project with its own:
- Memory directory (based on the worktree path, not the resolved git root)
- Project identity
Actual behavior
- All worktrees share the same project directory key (mapped to
backend-main) - Claude frequently navigates to sibling worktree directories (
backend_main/,backend_feature/) instead of staying in the current worktree - Memory files saved in one worktree would be loaded in another
- This issue does not occur on worktrees with unique repo paths (e.g., standalone clones)
Additional context
- OS: macOS (Darwin 25.3.0)
- A
CLAUDE.mdrule explicitly instructs Claude to stay within the worktree root, but the system-level project resolution overrides this in practice by anchoring the project identity to the wrong path. - The sandbox write permissions also reference
backend_maininstead of the current worktree, reinforcing the wrong path context.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗