General Error

How to fix "git submodule update" failed with 'fatal: detected dubious ownership in repository at...'

Quick summary

  • Seen in 2 public reports
  • Most common platform: linux
  • Last updated: May 4, 2026

Known variations

  • "git submodule update" failed with 'fatal: detected dubious ownership in repository at...'
  • Vagrant error : Failed to mount folders in Linux guest

Guide comparison

Field

Previous

LLM generated

Problem description

Git commands fail with 'fatal: detected dubious ownership in repository' when the repository or its parent directories are owned by a different user than the one running the git command. This is a security feature introduced in Git 2.35.2+ to prevent arbitrary code execution. The issue commonly occurs in containerized environments, shared systems, or when repositories are copied between users.

No enriched problem description is available yet.

Likely causes
  • Repository owned by a different user than the one running git
  • Parent directories in the path owned by a different user
  • Running git inside Docker containers with inherited file ownership
  • Files copied or moved between users without preserving ownership
  • Shared development environments with multiple users

No enriched causes are available yet.

Fix steps
  1. Check the current user running git commands with 'whoami'
  2. Check the owner of the repository and parent directories with 'ls -la /path/to/repo' and 'ls -la /' for each parent
  3. If you have sudo access, change ownership with 'sudo chown -R $(whoami):$(whoami) /path/to/repo'
  4. Alternatively, add the repository to git's safe directory list: 'git config --global --add safe.directory /path/to/repo'
  5. For submodules, also run 'git config --global --add safe.directory /path/to/repo/submodule' for each submodule
  6. To trust all directories under a path, use a wildcard: 'git config --global --add safe.directory '*'
  7. Verify the fix by running 'git status' or the original failing command again

No enriched fix steps are available yet.

Warnings
  • Using 'safe.directory *' trusts all repositories globally, which may have security implications in shared environments
  • Changing ownership requires appropriate permissions - you may need sudo or administrator access
  • The second source (Vagrant mount error) appears unrelated and may represent a different issue or misclustered data
  • This error is a security feature - bypassing it should only be done for trusted local repositories

No enriched warnings are available yet.

Enriched long-form guide

Users encountering this error see 'fatal: detected dubious ownership in repository at /path/to/repo' when running git commands, particularly 'git submodule update' but also git fetch, pull, push, and other operations. The error prevents any git operations on the repository. This error was introduced as a security fix in Git 2.35.2 (April 2022) in response to CVE-2022-24765, which prevented arbitrary code execution when working in directories owned by other users. The error occurs when the current user does not match the owner of the .git directory or any parent directory in the path. This is particularly common in Docker containers where files may be created by a different user, in development environments where files are copied or moved, or on shared systems where repositories were cloned by another user. The most reliable fixes involve either changing ownership of the repository to match the current user, or using git config to tell git to trust the specific repository despite the ownership mismatch.

Evidence

"git submodule update" failed with 'fatal: detected dubious ownership in repository at...'

stackexchange · 834516 views · score 423

Open source
Vagrant error : Failed to mount folders in Linux guest

stackexchange · 145757 views · score 284

Open source