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:

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:

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

The error should now no longer pop up.

1 thought on “Little Git Tricks: Fix a Dubious Ownership of a Repository”

  1. This is great information on how to fix it. I’m also interested in knowing how it happens. I had a repo that was working fine (on Windows) in the root of C drive. Suddenly today, I’m getting this error message. I’m trying to figure out what happened. So while the solutions are helpful, more detail would also be appreciated.

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.