Silence all safe.directory
warnings
tl;dr
Silence all warnings related to git’s safe.directory
system. Be sure to understand what you’re doing.
git config --global --add safe.directory '*'
Long version
Adapted from this post on I cannot add the parent directory to safe.directory in Git.
I had the same issue and resolved it by disabling safe directory checks, which will end all the “unsafe repository” errors.
This can be done by running the following command1:
git config --global --add safe.directory '*'
Which 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, which would be relevant in my case. 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 "*"