worktrunk
worktrunk copied to clipboard
[Bug] `wt switch` resolves to `.git/modules/` path inside git submodules
Summary
When using wt inside a git submodule, wt switch navigates to .git/modules/<submodule>/ instead of the actual submodule working directory.
Reproduction steps
-
Have a parent repository with submodules: parent-repo/ ├── .git/ │ └── modules/ │ └── my-submodule/ # git internal data └── my-submodule/ # actual working directory
-
cdinto the submodule and create a worktree:
cd parent-repo/my-submodule
wt switch -c feature/test
3. From the new worktree, switch back to main:
wt switch main
4. Expected: Shell navigates to parent-repo/my-submodule/
5. Actual: Shell navigates to parent-repo/.git/modules/my-submodule/
Cause
Git submodules store their actual git data in the parent repo's .git/modules/<name>/ directory. The submodule's .git is a file containing:
gitdir: ../../.git/modules/my-submodule
It seems wt resolves the primary worktree path using this gitdir reference, which points to the internal git data directory rather than the submodule's working directory.
Environment
- worktrunk: v0.24.1
- git: 2.49.0
- OS: macOS
---