git,

Resolve 'fatal: detected dubious ownership in repository at' in Git

Sep 16, 2023 · 1 min read · Post a comment

The error message fatal: detected dubious ownership in repository at.. happens when Git detects that the current user is not owner of the Git repo directory.

Prerequisites

  • Git

Solution(s)

As for the solutions, try the following:

  • Make sure the current user running is owner of the .git directory e.g. chown -R <user> <directory>.
  • Run sudo -u user git <the_rest_of_the_command>.
  • Run git config --system --add safe.directory '<directory>'. If that doesn’t work try with --global instead of --system.
  • Update locals .gitconfig usually found under $HOME directory. For example:
    [safe]
      directory = <directory_path>
    

Conclusion

In case you face any issues, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.