. Advertisement .
. Advertisement .
“Fatal: detected dubious ownership in repository” is an error that I used to encounter and I have tried several ways to solve it. I want to share some possible solutions with everyone in this article. If you are also facing this problem then read on to get the answer.
How does the error “fatal: detected dubious ownership in repository” happen?
You may get this error when trying to plug the hard drive into a Linux workstation and download a new repository on the new disk thus when you did the command: git submodule update –init –recursive, the error happened immediately, and look like this:
fatal: detected dubious ownership in repository at '/media/data/users/jhu3szh/serialize'
To add an exception for this directory, call:
git config --global --add safe.directory /media/data/users/jhu3szh/serialize
fatal: detected dubious ownership in repository
You need to make sure you have the proper permissions in your project directory or else the error: “fatal: detected dubious ownership in repository” will occur. The repositories must be made sure that they belong to the right owner ID or you can skip security.
Some ways that you can try are to change directory ownership or add a safe directory. Next, I will dive into each solution.
How “fatal: detected dubious ownership in repository” error can be solved?
Solution 1: Change Directory Ownership
One of the simplest ways to fix “fatal: detected dubious ownership in repository” is that you just need to change the ownership with the command below:
chown -R <current_user> <repo_folder>
With this solution, the error can be fixed.
Solution 2: Add Safe Directory
Besides changing ownership manually you can add the safe directory as this will clean up all the errors related to unsafe repositories in a flash just by disabling checks. You need to type the below command to disable it.
git config --global --add safe.directory '*'
The error “fatal: detected dubious ownership in repository” will be resolved because using this command will change the directory’s configuration to [safe] directory = *
directory = *
Don’t worry if git config –global –add safe.directory ‘*’ doesn’t give satisfactory results, try applying git config –global –add safe.directory “*”. You just need to replace single quotes in git config –global –add safe.directory ‘*’ command with double quotes. Extremely simple but that will help the command to be run smoothly.
However, you also need to know the consequences of using solution 2, along with disabling the safe folder. And in case the repositories are kept on shared storage then you don’t need to disable the secure directory.
And another thing is that you can completely disable the safe folder manually but only when the repositories are kept on the computer and cannot be accessed by unauthorized people.
I hope that the solutions I mentioned above can help you to solve the error: “fatal: detected dubious ownership in repository” effectively. Leave a comment below with your thoughts and let me know the solution that works best for you. Good luck in fixing the error, thank you.