Submodule project path derived from .git/modules/ instead of working directory
Status Fixed / completed
Maintainer reply None cached
Activity 4 comments · opened Mar 25, 2026 · closed Mar 25, 2026
Summary
When Claude Code runs inside a git submodule, the project path (used for ~/.claude/projects/<key>/) is derived from the git metadata path (.git/modules/...) instead of the actual working directory.
Reproduction
- Have a repo with a git submodule (e.g.,
parent-repo/submodule/) - Launch Claude Code from the submodule directory
Expected: Project dir key derived from the working directory:
~/.claude/projects/-Users-me-Dev-parent-repo-submodule/
Actual: Project dir key derived from git metadata path:
~/.claude/projects/-Users-me-Dev-parent-repo--git-modules-submodule/
Root cause
Likely using git worktree list --porcelain to determine the working directory. For submodules, the main worktree entry returns the bare git metadata directory:
$ cd parent-repo/submodule
$ git worktree list --porcelain
worktree /Users/me/Dev/parent-repo/.git/modules/submodule
HEAD abc123
branch refs/heads/main
git rev-parse --show-toplevel returns the correct path:
$ git rev-parse --show-toplevel
/Users/me/Dev/parent-repo/submodule
Impact
The submodule gets an unexpected project key, so project-scoped state (memory, settings) is stored under a path that doesn't correspond to the actual working directory.
4 Comments
Found 1 possible duplicate issue:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Per the memory docs:
So the intent is for all worktrees to share one project directory. For submodules, they're getting a separate project key derived from
.git/modules/instead, which breaks this.Closing as duplicate of #29256 — same root cause (git submodule worktree path resolved from
.git/modules/instead of the actual working directory).This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.