1

Last week I created a git repo for a project. This morning, I tried git status which results in fatal: detected dubious ownership in repository at 'C:/ProjectPath/ProjectName'.

I believe I created the git repository using an administrator command prompt, so I tried git status in an administrator command prompt and it works. The same results happen when I use the Git Bash: it works when run as an administrator.

How can I change the repo's ownership to allow non-administrative usage? This SO question suggests multiple solutions using sudo; however, these are not applicable to git for windows: sudo echo test returns bash: sudo: command not found.

torek
  • 448,244
  • 59
  • 642
  • 775
  • 1
    I would recommend to check permissions of the repo to make sure that you can read/write on it.... otherwise, the error message should display a command that would allow you to setup the repo to allow you to get access to it. – eftshift0 Sep 26 '22 at 16:32
  • 1
    `git config --global --add safe.directory \path\to\project\` solved the problem. I'd prefer to have been able to change the file ownership, but couldn't find out how to properly find the user I wanted because of Azure AD. – Zach Longhofer Sep 26 '22 at 16:57
  • `sudo` is for Unix-like systems. Windows has a much more complicated file permissions model than Unix-ish / POSIX; even POSIX ACLs don't cover all the Windows settings. I don't "do" Windows so I can't tell you how to fix it there, just that it's complicated. – torek Sep 26 '22 at 19:38

0 Answers0