↑ ↓ select, Enter open, Esc close

Fix the Git error dubious ownership on servers

Caution: This command changes the system. Understand what it does before you run it.

Adjust the values, the command updates live
user@server
git config --global --add safe.directory /var/www/vhosts/example.com/httpdocs

Adds 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

Related one-liners

All in Git

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.