Fix the Git error dubious ownership on servers
fatal detected dubious ownership in repository | git as root in vhost directory not working | git unsafe repository error | git | safe-directory | permissionsCaution: This command changes the system. Understand what it does before you run it.
git config --global --add safe.directory /var/www/vhosts/example.com/httpdocsAdds the directory to the global Git configuration of the current user as trusted. The error message detected dubious ownership appears since Git 2.35.2 when a repository belongs to another user, typically when working as root in Plesk vhosts. The entry only applies to the user who runs the command.
Note: A cleaner approach is to run Git as the owner of the repository, for example with sudo -u webuser git pull. Only use the value * for all directories if no untrusted users can create repositories.
Also searched as
- fatal detected dubious ownership in repository
- git as root in vhost directory not working
- git unsafe repository error