Fatal: detected dubious ownership in repository

Created at 12-Jul-2023 , By samar

The error message "fatal: detected dubious ownership in repository" typically occurs when there are ownership or permission issues within the Git repository. You have to  change the repository ownership or you can add the repository to safe.dir (These config entries specify Git-tracked directories that are considered safe even if they are owned by someone other than the current user)  list.

Change the owner of the repository folder to the user which is running the git command

For windows : 


takeown /f <path to the repository> /r /d y

Example : 

takeown /f C:/laragon/www/learngit  /r /d y

Replace <path to the repository> with your own repository path.

For Linux 


chown -R username:group <path to the repository>


chown -R username:group C:/laragon/www/learngit

You can run the whoami command to get the username.

Single repository on a multi user system

The default solution to workaround this issue would be to add the directory to the git safe.directory list. 


git config --global --add safe.directory <path to repository>


git config --global --add safe.directory C:/laragon/www/learngit

This is usually the command suggested by git in the error message to add this directory to the exception list after executing the git command.

Multiple repositories, system global settings.

Add the folder to the safe.directory list at the system level rather than the user or repository level. System-level configuration affects all users on the system.

git config --system --add safe.directory <path to the repository>

git config --system --add safe.directory C:/laragon/www/learngit

If using git > 2.36, there's also a wildcard to add all folders to safe.directory list.

You can check your git version using git —version command on terminal.

For the current user and all repositories.

git config --global --add safe.directory '*'

For all users and all repositories.

git config --system --add safe.directory '*'

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.