Little Git Tricks: Fix a Dubious Ownership of a Repository

If something goes wrong with the permissions of your Git repository, you may end up with an error like this:

git status

fatal: detected dubious ownership in repository at 'C:/my/Repo' To add an exception for this directory, call:

git config --global --add safe.directory C:/my/Repo

Set the environment variable GIT_TEST_DEBUG_UNSAFE_DIRECTORIES=true and run again for more information.

If this happens with your repository, you can first change the ownership of everything in that repository to your user with this Linux command:

chown -R my_user C:/my/Repo

If the error persists, follow along with the described approach and add your repository into the safe dictionary list of Git:

git config --global --add safe.directory C:/my/Repo

The error should now no longer pop up.