Bug Description
Suppose you are logged into Windows as an ITretyakov account.
Your user profile directory would be C:/Users/ITretyakov.
You have a service account named as some_automoation.
And you're opening CMD console by using "Run as a different user" for the some_automoation account.
But what's important, your startup directory will be C:/Users/ITretyakov.
And some_automoation account has no any access rights for this directory.
Run
git config --global --list
and you'll receive the following error
fatal: failed to stat 'C:/Users/ITretyakov': Permission denied
Git wants to read current working directory and fails on it.
Now set working directory to the system drive (C:) or to any another location.
CD /D %SYSTEMDRIVE%\
git config --global --list
and you'll receive another expecting error
fatal: unable to read config file 'C:/Windows/system32/.gitconfig': No such file or directory
and finally we use the fix of zdenko.s
SET HOME=%USERPROFILE%
Now you are ready to access .gitconfig of the some_automoation account that is located in
C:/Users/some_automoation
Conditions:
git version 2.21.0.windows.1;
Windows 10
Workaround
I would recommend to use
in CMD
CD /D %SYSTEMDRIVE%\
@REM Or just use "CD .."
SET HOME=%USERPROFILE%
I.e. when you start CMD by using "Run as a different user" you must move out of the home directory of your Windows logon user.
But in bash will be enough to use
HOME=$USERPROFILE
because bash has another default startup folder.