Home › Git

fatal: detected dubious ownership in repository — how to fix

fatal: detected dubious ownership in repository at '/path/to/repo'
To add an exception for this directory, call:

        git config --global --add safe.directory /path/to/repo

Quick fix: If you trust the repo, run git config --global --add safe.directory /path/to/repo. Better: fix ownership with sudo chown -R $(whoami) /path/to/repo.

What it means

Since Git 2.35.2, Git refuses to read a repository whose files belong to a different user than the one running Git. A malicious .git/config in a shared folder could otherwise make Git run commands as you.

Fix 1: take ownership (best when it's your project)

sudo chown -R "$(whoami)" /path/to/repo

Fix 2: mark the directory as safe

git config --global --add safe.directory /path/to/repo

To trust every directory (only on single-user machines or throwaway containers):

git config --global --add safe.directory '*'

Common situations

Last updated 2026-10-27.