Fix guest VM git operations for worktrees and ownership mismatch#48
Open
Fix guest VM git operations for worktrees and ownership mismatch#48
Conversation
Three fixes for git operations failing inside the guest VM: 1. Change sanitized .git/config permissions from 0600 to 0644. The config contains no credentials (stripped by SanitizeConfig) but was unreadable by the guest UID due to ownership mismatch. 2. Always write ~/.gitconfig with [safe] directory = /workspace. Git 2.36+ rejects repos owned by a different UID (host 501 vs guest 1000) without this setting. The gitconfig is now written unconditionally, even without identity or token configured. 3. Create minimal git structure (HEAD, objects/, refs/) for worktree snapshots so git recognizes them as valid repositories. Detached HEADs fall back to a symbolic ref to avoid errors with empty objects/. The resolved gitdir is validated (must contain HEAD) to prevent path traversal, and HEAD content is filtered to require "ref: refs/" prefix. Known limitation: worktree snapshots show "No commits yet" because the object database lives in the main repo's .git/objects/ which is outside the workspace mount. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
JAORMX
approved these changes
Mar 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.git/configpermissions (0600→0644) so guest UID can read the sanitized config[safe] directory = /workspaceto guest~/.gitconfigunconditionally to prevent git 2.36+ "dubious ownership" errorsKnown limitation
Worktree snapshots show "No commits yet" because the object database lives in the main repo's
.git/objects/which is outside the workspace mount.Test plan
task fmt && task lint && task test— all passgit statusworks in VMgit statusworks (no errors), but shows no commits (known limitation)🤖 Generated with Claude Code