# Investigate Git’s dubious-ownership warning safely

Canonical: https://githtml.com/guides/git-dubious-ownership-safe-directory
Published: 2026-11-23
Publisher: WaveTech LLC / gitHtml

Git’s dubious-ownership warning means repository ownership does not match the trust expectations of the current user. Verify who owns the directory and why before trusting it. Correct an accidental ownership problem through the appropriate administrative process, or add only a specific trusted repository exception. Do not use a wildcard safe.directory setting as a routine workaround.

## Understand the security boundary

Repository configuration and related mechanisms can influence Git behavior, so operating in a directory controlled by another user has security implications. The ownership check is not simply an annoying filesystem permission error. A copied checkout, container bind mount, shared volume, or earlier use of sudo can explain the mismatch, but the explanation still needs verification.

Inspect the exact repository path and its owner using the operating system’s file information or administrative tools. Determine whether the directory is controlled by you, a trusted collaborator, or an unknown source. If you only need unfamiliar source files, a fresh authorized clone under your own account may be clearer than trusting someone else’s mutable checkout.

## Choose correction or a narrow exception

If files accidentally belong to another account, ask the responsible administrator to correct ownership for the exact intended repository. Avoid recursive ownership changes across a home directory or shared workspace. If shared ownership is intentional and the repository is trusted, Git documents safe.directory exceptions in protected configuration. The example is inspection, not blanket trust.

1. Before adding an exception, verify the absolute path and the account controlling it. A similarly named directory or symlink can change the actual trust target.
2. Never use safe.directory=* merely to make all warnings disappear; it disables the ownership-based protection broadly rather than resolving this repository’s situation.

````shell
git config --show-origin --show-scope --get-all safe.directory
git --version
````

## Verify the resulting trust decision

After a targeted correction, run a limited status or history inspection and confirm the repository is the one you intended. Do not immediately execute its build scripts or hooks as proof that access works; trusting Git metadata and running arbitrary project code are separate decisions.

Document why the exception exists, especially on shared machines or container setups. Remove obsolete exceptions through a deliberate review when the directory is no longer used. If ownership keeps changing, fix the process creating the files rather than accumulating exceptions. The repair is complete when the ownership model is understood and the narrow trust decision matches it, not when Git stops warning for every repository on the machine.

1. For a container-mounted checkout, compare the container user’s identity with the host-side owner through the environment’s documented tools. A numeric ownership mismatch can be expected even when the directory is legitimate. Establish who can modify it before choosing an exception or changing the mounting workflow.
2. If an exception was added for a temporary shared directory, review it when that directory is reassigned or replaced. Trust attaches to a path, while the party controlling that path can change. Remove obsolete trust through an intentional configuration review rather than assuming the original decision remains valid indefinitely.

## Sources and further reading

- [Git reference: git-config](https://git-scm.com/docs/git-config)
- [Git reference: git](https://git-scm.com/docs/git)

## Related guides

- [Diagnose a Git diff that marks every line changed](https://githtml.com/guides/git-entire-file-changed-line-endings)
- [Find which Git ignore rule hides a new file](https://githtml.com/guides/git-file-missing-because-ignored)
- [Diagnose GitHub HTTPS authentication failures](https://githtml.com/guides/git-github-https-authentication-failed)
- [Fix GitHub SSH “Permission denied (publickey)” carefully](https://githtml.com/guides/git-github-permission-denied-publickey)

Editorial approach: https://githtml.com/guides/about
