You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
claude-code template: VS Code's Git extension intermittently hits "dubious ownership" on /workspace, and SSH GitHub remotes can't use the container's gh login #172
1. "dubious ownership" on the bind-mounted workspace. In containers built from the claude-code template on Docker Desktop for Mac, VS Code's Git log (~/.vscode-server/data/logs/*/exthost*/vscode.git/Git.log) repeatedly shows:
fatal: detected dubious ownership in repository at '/workspace'
[GitHistoryProvider] ... "gitErrorCode": "NotASafeGitRepository"
It isn't limited to startup. In one container it recurred over several hours, and running git status by hand at the same moments usually succeeds.
Once the Git extension hits it, Source Control goes blank or stale until the window is reloaded.
A safe.directory entry written into ~/.gitconfig doesn't reliably help, because that file is managed or copied by the Dev Containers extension.
2. SSH-style GitHub remotes don't work inside the container. The template persists the GitHub CLI login in a volume (~/.config/gh), but gh only authenticates HTTPS. Repos whose remotes are [email protected]:… fail inside the container with Permission denied (publickey). The Dev Containers extension forwards only the host's default ssh-agent, and that often has no keys when the host uses another agent (Secretive, 1Password) or on-disk keys.
Proposal
Set git options for every process in the container through env-based config. It outranks ~/.gitconfig, doesn't touch the host, and needs no extra files. Add this to containerEnv in both devcontainer.json variants:
safe.directory=/workspace removes the ownership check for the one bind-mounted repo.
The insteadOf rewrite and the gh credential helper let SSH-style remotes work inside the container, using the persisted gh auth login. The host keeps its SSH setup, and the remotes themselves don't change.
This was checked in a running container by passing the same variables to a single command:
The 3-entry version isn't enough on its own. VS Code injects its own credential helper into /etc/gitconfig and ~/.gitconfig. Git tries it first, and it answers with the host's GitHub credential, which may be stale. git push then fails with "Invalid username or token" even though gh is signed in.
The fix is an empty credential.https://github.com.helper entry before the gh one. It resets the helper list for github.com only, so other hosts keep VS Code's helper:
Inside a container, git config --get-regexp credential shows the VS Code helper (a vscode-remote-containers-*.js git-credential-helper function) next to these entries. Pushes go through gh only when the empty entry is present.
Verified in a downstream project built from this template: with three entries pushes fail as above, with the fourth they go through gh.
Activity
gatezh commentedon Oct 7, 2026
The 3-entry version isn't enough on its own. VS Code injects its own credential helper into
/etc/gitconfigand~/.gitconfig. Git tries it first, and it answers with the host's GitHub credential, which may be stale.git pushthen fails with "Invalid username or token" even thoughghis signed in.The fix is an empty
credential.https://github.com.helperentry before theghone. It resets the helper list for github.com only, so other hosts keep VS Code's helper:Inside a container,
git config --get-regexp credentialshows the VS Code helper (avscode-remote-containers-*.js git-credential-helperfunction) next to these entries. Pushes go throughghonly when the empty entry is present.Verified in a downstream project built from this template: with three entries pushes fail as above, with the fourth they go through
gh.