[Solved] Fatal error "unsafe repository ('/home/repon' is owned by someone else)"
Problem:
Here I got an error log from Apache 2 that is fatal:
unsafe repository ('/home/repon' is owned by someone else)
I have git rev-parse --symbolic-full-name --abbrev-ref HEAD'
in my PHP code , and it seems that new Git safety change no longer allows www-data
to run this Git command.
git config --global --add safe.directory /homerepon
does not work. How can I solve this issue?
Git version: 2.35.3
PHP version: 7.4
Apache 2 version: 2.4.41
Solution:
This error is happend because of the Git safe update.
To make Git trust any directory you can run this in PowerShell:
git config --global --add safe.directory *
In Bash, you should escape the *
to avoid expansion:
git config --global --add safe.directory '*'
If you just trust one directory, you can run this command
git config --global --add safe.directory your-directory
Thank you for reading the article. If you face any further problem feel free to contact us.