I moved to Linux from Windows. And auto-mounted my extra drive[hdd] to a directory I created in Home.

After hitting git status or any git command I get this message: fatal: detected dubious ownership in repository at /home/my-name/folder/sub-folder/sub-folder1 As suggested in other Stackoverflow questions with this error, I thought this is an ownership issue and would fix with something like the equivalent of TAKEOWN command in Windows. So, I run chown -R <username> <repo-dir> and chown -R <username:groupname> <repo-dir> but nothing seems to work.

Should I just go with git config --global --add safe.directory /home/my-name/folder/sub-folder/sub-folder1. I am hesitant to go with this because I don't understand why it is fatal in the first place and whether making it safe would have some implications?

I am on PopOS 22.04 and git 2.42.0

1

There are 1 best solutions below

0
Avijit Dey On

I have solved this issue. The problem was I was enabling auto-mounting on my extra drive[hdd] and mounting it to a folder at Home. When doing this, my OS was changing the ownership (user and group) to root. You need to change the ownership back to YOUR user and group. To know your user and group name, open terminal and type id and enter. You will something like this: enter image description here
Note the ids for your user(uid) and groups(gid). In my case uid=1000 and gid=1000, "avi" is the user name here.

Now, open "Disks" utility(also known as gnome-disks) for Gnome users. (If you're in KDE, look for "partitionmanager") Select your extra drive -> settings -> edit mount options. enter image description here

Then add ,uid=1000,gid=1000 like shown enter image description here

Hopefully, this will fix your problem if your issue is similar to mine.