Skip to content

[Bug] wt switch resolves to .git/modules/ path inside git submodules #1069

Closed

Description

@SokiKawashima

Summary

When using wt inside a git submodule, wt switch navigates to .git/modules/<submodule>/ instead of the actual submodule working directory.

Reproduction steps

  1. Have a parent repository with submodules:
    parent-repo/
    ├── .git/
    │ └── modules/
    │ └── my-submodule/ # git internal data
    └── my-submodule/ # actual working directory

  2. cd into 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


---

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions