After updating Git to v2.35.2.windows.1
I'm getting the following error:
fatal: unsafe repository ('F:/GitHub/my-project' is owned by someone else)
To add an exception for this directory, call:
git config --global --add safe.directory F:/GitHub/my-project
I've tried adding the parent directory of my projects to .gitconfig
, but it doesn't work.
[safe]
directory = F:/GitHub/
directory = F:/Private/
I don't want to add every single project I'm working on to the .gitconfig
file.
Starting in Git v2.35.3, safe directory checks can be disabled, which will end all the "unsafe repository" errors (this will also work in the latest patch versions of 2.30-34).
This can be done by running:
git config --global --add safe.directory '*'
1
It will add the following setting to your global .gitconfig
file:
[safe]
directory = *
Before disabling, make sure you understand this security measure, and why it exists. You should not do this if your repositories are stored on a shared drive.
However, if you are the sole user of your machine 100% of the time, and your repositories are stored locally, then disabling this check should, theoretically, pose no increased risk.
Also note that you can't currently combine this with a file path, as the command doesn't interpret the wildcard *
as an operator per say– it just takes the "*"
argument to mean "disable safe repository checks/ consider all repositories as safe".
1 - If this fails in your particular terminal program in Windows, try surrounding the wildcard with double quotes instead of single (Via this GitHub issue):
git config --global --add safe.directory "*"