Got the below error message for a simple git status
. I pretty much know the reason, last week in my Windows 11 encountered “blue screen of death”, due to which i had to reinstall Windows and in the process i had changed system username.
D:\20230422 - BigData\3. Java\Workspaces>git status
warning: safe.directory ''*'' not absolute
fatal: detected dubious ownership in repository at 'D:/20230422 - BigData/3. Java/Workspaces'
'D:/20230422 - BigData/3. Java/Workspaces' is owned by:
(inconvertible) (S-1-5-21-1705801831-2303169435-1930423522-1001)
but the current user is:
SUSHANTH/bobby (S-1-5-21-2182514462-352722902-1933051922-1001)
To add an exception for this directory, call:
git config --global --add safe.directory 'D:/20230422 - BigData/3. Java/Workspaces'
You just have to change the ownership of all folders
-
Go to the parent folder
-
Right-click, Properties
-
Select “Security” tab
-
Click Advanced
-
Click Change
-
Enter the current System username and Click Check Names
-
If you don’t know the current username. In the command prompt enter
echo %USERNAME%
-
Click Checkbox then Apply
Now, click OK and close the properties. Open the Properties ⇒ Security ⇒ Advanced
- Now you can see the Owner name has changed
Now go back to Git and Retry