Git Dubious Ownership on Remote Repository

A couple of days ago I suddenly got the following error, when pulling from a remote Git repository using SSH:

fatal: detected dubious ownership in repository at '/some/repository'
To add an exception for this directory, call:

        git config --global --add safe.directory /some/repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I did as advised, and added /some/repository as safe directory. But the error remained.

Adding the repository to the list of safe directories did not work.

Turns out: You had to change the Git config on the server hosting the repository.

For this, a server administrator needs to execute sudo git config --system --add safe.directory '/some/directory' on the server.

If the server hosts more than one repository she may also execute sudo git config --system --add safe.directory '*'. This will mark all repositories on this server as safe.

Published: May 31 2024