--mount-git-worktree-common-dir silently ignored when devcontainer.json sets a custom workspaceMount
@v-Mathiyarasy is already working on this.
Since Jun 11, 2026.
Assessment
This issue has not been assessed yet.
Description
Summary
--mount-git-worktree-common-dir (added in #1127) has no effect when the devcontainer.json defines a custom workspaceMount. The worktree common-dir bind mount is never added, so in-container git fails with fatal: not a git repository for any git worktree whose devcontainer uses a custom workspaceMount.
Root cause
In src/spec-node/utils.ts (getWorkspaceConfiguration, ~L386) the entire worktree detection + common-dir mount block is guarded by:
if (workspace && (!workspaceFolder || !('workspaceMount' in config))) { ... }
When workspaceMount is present, the block is skipped — the .git file is never read, the common dir is never resolved, and no mount is added. (Flagged as a possible oversight by @kapouer in #796, Mar 2026.)
Reproduction (CLI 0.82.0, git 2.52)
git init main && (cd main && git commit --allow-empty -m init && git worktree add --relative-paths ../wt)- Add
wt/.devcontainer/devcontainer.jsonwith a customworkspaceMount, e.g.:{ "image": "mcr.microsoft.com/devcontainers/base:debian", "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", "workspaceFolder": "/workspace" } devcontainer up --workspace-folder wt --mount-git-worktree-common-dir truedevcontainer exec --workspace-folder wt -- git -C /workspace status→fatal: not a git repository: (null)docker inspecton the container shows only the workspace bind mount; the worktree common dir was not mounted.
Removing workspaceMount makes it work — confirming the guard is the cause.
Expected
The common-dir mount should be computed and added even when a custom workspaceMount is set, by resolving the mount target relative to the configured workspaceMount target / workspaceFolder. This is the common case for monorepos that mount a parent directory and set workspaceFolder to a subpath. Relates to #796.
Workaround
Adding the common dir manually via a mounts entry (binding the main repo's .git to the path the worktree's .git file resolves to inside the container) restores in-container git — matching the maintainer's earlier suggestion in #796.
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 461
- Avg merge
- 18m
- Merged PRs (30d)
- 5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from devcontainers/cli
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
devcontainers/cli#1203 ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
devcontainers/cli#1178 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
devcontainers/cli#1308 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 78/100
devcontainers/cli#1307 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
devcontainers/cli#1305 ·
All issues in devcontainers/cli
Similar issues
-
clawsweeper:linked-pr-open clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:message-loss issue-rating: 🦞 diamond lobster maturity:stable P2
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#616 ·
-
ZCode 3.14.3 に対応する Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
supermomonga/zcode-acp#24 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
growthbook/growthbook#7100 ·
-
triage
Difficulty 1/5 1-3 hours Newbie friendliness 88/100