0

When I run git status, git branch --track, git fetch --all, git pull --all inside a git repository stored inside an Azure Blob Storage mapped to an Azure virtual machine with Windows 11 and Git for Windows version 2.37.3, I get the following error:

fatal: detected dubious ownership in repository at '<path>'
'<path>' is owned by:
'S-1-5-18'
but the current user is:
'S-1-5-21-1990399924-2863569968-2306271318-500'
To add an exception for this directory, call:

        git config --global --add safe.directory '%(prefix)///<path>'

I have tested:

git config --global --add safe.directory '%(prefix)///<path>'

and

git config --global --add safe.directory '*'

and change directories and files permissions:

TAKEOWN /F * /R

But when I do all this in a local folder of the virtual machine everything works perfectly.

1 Answers1

0

I tried to reproduce same in my environment I got the error like below.

![enter image description here](https://i.imgur.com/AqUPS02.png)

This error usually occurs When git will determine whether the current user is the owner of the git repository folder. if not, it will display the error like below because if the folder is not owned by the currently logged-in user, harmful files may be added there by other users.

To resolve the issue:

You can make use of this command.

git config --global --add safe.directory <path>

As you tested above command already, try the below workaround:

Select the folder of the git warehouse. If this folder is full of git warehouses, you can select the entire folder or select your file -> properties -> security -> advanced like below:

enter image description here

If the owner is not same as current windows login account, click to change.

enter image description here

enter image description here

Click Find Now and search your current account name and click okay.

enter image description here

enter image description here

Refer this SO thread by halt9k to disable inheritance.

When I tried to use git status or git log now error doesn't occur like below:

enter image description here

Imran
  • 3,875
  • 2
  • 3
  • 12