Searching for "git default home directory" will easily net some third party statements that the user folder C:\Users\<account>
is said directory.
In practise, this generally holds: Grab a Windows PC without Git, install Git from any source, set a variable in global config => C:\Users\<account>\.gitconfig
is created and read by Git.
Now for the second time, I have a system here, where this path spuriously changes to H:\.gitconfig
and back - H: being a network drive accessible only via Cisco AnyConnect VPN.
Defining HOME overrides this behaviour, but
- it messes up unrelated things
- I would like to understand what happens.
I was not able to find official documentation on this matter, although I expect it must exist.
Reasons I was able to exclude:
- It is not USERPROFILE - that variable never changes away from
C:\Users\<account>
. - It is not a conditional configuration include.
- There is no HOME set directly in the profile file.
- There was no HOME environmental variable defined before I added mine.
- It is not a corrupted PATH.
Might or might not be related:
- So far I have only seen this interaction with Cisco AnyConnect VPN (not other VPN clients) and a network drive called H: (not other network drive letters).
git --version
is 2.40.0.windows.1 on the machine currently exhibiting this issue. (I no longer have access to the older one, but I think it had about 2.24.x.windows.y .)- All uses of Git have been via cmd.
- The respective IT departments providing either affected machine claimed to not have any configuration (e.g. group policies) in place, that could explain (aka cause) this behaviour. (And indeed, outside of git, no program seems to automatically put files onto H: - there is only what I put there manually and vestigial files .gitconfig, .lesshst, .viminfo created whenever I dare to use Git at the wrong time.)
- I have colleagues who claim it does not happen on their machines, even though nominally those should be configured identically.
- Other people have reported their global .gitconfig to reside on network drives, but none of them noted the location to move around. The well-known/expected/normal way this happens is that USERPROFILE and all point to the network drive and trying to use programs offline simply produces hard errors (there is no automatic fallback to a different path).