Re: Location of git config on Windows
- From
- Daniel Corbe <corbe@corbe.net>
- Date
- Aug 18, 2014, 15:14 UTC
- Message-ID
- <ygflhqlvni7.fsf@corbe.net>
- In-Reply-To
- <53F135F8.60508@gmail.com>
Karsten Blees <karsten.blees@gmail.com> writes:
Show 29 quoted lines
> Am 18.08.2014 00:01, schrieb Erik Faye-Lund: >> On Sun, Aug 17, 2014 at 10:18 PM, Daniel Corbe <corbe@corbe.net> wrote: >>> >>> I installed git on my Windows machine while it was connected to my >>> corporate network. It picked up on that fact and used a mapped drive to >>> store its configuration file. >>> >>> As a result, I cannot currently use git when disconnected from my >>> network. It throws the following error message: fatal: unable to access >>> 'Z:\/.config/git/config': Invalid argument >>> >>> Obviously this value is stored in the registry somewhere because I made >>> an attempt to uninstall and reinstall git with the same results. >>> >>> Can someone give me some guidance here? >> >> Git looks for the per-user configuration in $HOME/.gitconfig, and if >> $HOME is not set, it falls back to $HOMEDIR/$HOMEPATH/.gitconfig. My >> guess would be some of these environment variables are incorrectly set >> on your system. > > To be precise, git checks if %HOME% is set _and_ the directory exists before > falling back to %HOMEDRIVE%%HOMEPATH%. > > If %HOMEDRIVE%%HOMEPATH% isn't set or the directory doesn't exist either, it > falls back to %USERPROFILE%, which is always local (C:/Users/<yourname>), even > if disconnected from the network (at least that's how its supposed to be). > >
Awesome! Thanks for the advice.
%HOMEDRIVE% and %HOMEPATH% are indeed set by my system and point to an (often disconnected) network drive. I manually forced %HOME% to %USERPROFILE% and it works like a charm now.
I would argue that on Windows %USERPROFILE% should be checked first (or at least after %HOME%).
Best, Daniel