GIT Repository appears to be owned by another user on your machine
Asked Answered
H

4

9

I have a git repository as a mapped network on my machine on my "Y:" drive. Until recently I was able to connect to the repository from my git desktop application. But for the last two days it throws an error

"GIT Repository appears to be owned by another user on your machine"

What could be possible cause for this error.

Hardpan answered 16/4, 2022 at 3:52 Comment(6)
Git has recently (due to a CVE) started caring about repository ownership: if you don't own some repository, the person who does can set that repository up to steal your privileges via a Trojan-horse. The new "don't trust" code can be overly paranoid for some people in some situations so it's configurable. See this question for instance.Tonometer
Thank you for this information. It helped.Hardpan
@MACMAN, how did you solve the issue in the end? I currently have the same problem on Windows but I did not find a solution so far, also with the hints given in the question mentioned above.Zondra
I installed Git desktop in my ubuntu machine and manage my local ubuntu repository from the ubuntu machine itself. Now I no longer depend on shared folder.Hardpan
My Visual Studio git no longer detects changes in my code. I added the local repository in Github Desktop then I got the above message. I added as dir exception and it works. However Visual Studio git still isn't working. This happens yesterday when I;d update Visual Studio.Euphuism
Got a link to that CVE?Struble
S
11

(Using Windows and GitHub Desktop. Also Not using a shared folder)

Not sure if this could help anyone.

I got this message and it seemed weird to me as I previously managed to add other repositories similar to the one I was facing an issue with. Also, I was not using a shared folder.

Turns out, I only needed to open GitHub Desktop as an Admin.

Sausauce answered 27/11, 2022 at 8:30 Comment(1)
Turns out, I only needed to open GitHub Desktop as an Admin. This is the answer!Allotment
H
3

If it still doesn't work, even if you ran Github Desktop as administrator, you need to add your repository as a secure directory in the (.gitconfig) file.

If you don't have [safe] in your (.gitconfig) you have to add the following: [safe] directory = [directory path]

However, you still have to keep in mind that backslashes do not work.

Helper answered 2/3, 2023 at 14:28 Comment(0)
K
2

I got this error fatal: detected dubious ownership in repository at ... because I did a bunch of Git operations with Windows Terminal running as Administrator then I switched to a normal user.

This command running as a non-administrator Powershell fixed it:

takeown /f .\path_to_git_repo /r
Kaif answered 22/1 at 19:3 Comment(0)
H
0

I solved this issue myself by installing Git desktop in my ubuntu machine and managing my local ubuntu repository from the ubuntu machine itself. Now I no longer depend on shared folder.

Hardpan answered 21/4, 2022 at 4:53 Comment(1)
Ok, thanks for the response. For those using windows and GitHub Desktop, there is since yesterday the possibility to add an exception for a git repository located on a shared network, which solved my issue.Zondra

© 2022 - 2024 — McMap. All rights reserved.