All the time I am running Visual Studio with elevated rights to access Windows 10 services and this works fine. However, once I clone new GIT repository the VS creates folders with wrong owner which results in various problems. For example trying to fetch using git command line shows fallowing error:
d:_PROJECTSProject1>git fetch
fatal: detected dubious ownership in repository at 'D:/_PROJECTS/Project1'
'D:/_PROJECTS/Project1' is owned by:
'S-1-5-32-544'
but the current user is:
'S-1-5-21-179508888-00000000005-000000000-000000'
To add an exception for this directory, call:
git config --global --add safe.directory D:/_PROJECTS/Project1
Using TortoiseGIT does not show any branches at all and VS2022 always showing repository as disconnected. The problem can be fixed by simply changing owner and then inheriting change for all children folders.
With my older laptop I never had such a problem but now its gone and I can’t find out differences with my new PC. How to fix this problem that elevated Windows 10 application running under user account creates folders with user’s ownership instead of Administrator?
Environment: Windows 10 21H2 with ADO. My account is listed under administrators group (Local Users And Groups settings).