git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 17:29 UTC

Re: Location of git config on Windows

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
Aug 18, 2014, 15:25 UTC
Message-ID
<CABPQNSZ=BKqNPCWUmaCSz+gJtBRhjkWtpcDbirsV+KJX=c0kpg@mail.gmail.com>
In-Reply-To
<ygflhqlvni7.fsf@corbe.net>
On Mon, Aug 18, 2014 at 5:14 PM, Daniel Corbe <corbe@corbe.net> wrote:
Show 41 quoted lines
>
> Karsten Blees <karsten.blees@gmail.com> writes:
>
>> 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%).
Why? Then people won't be able to have their config files on network-shares, no?

I think a somewhat better approach would be to resolve the home directory lazily, unless %HOME% is set. That way we can check that %HOMEDRIVE%%HOMEPATH% actually exists as it's being accessed. Or you could just restart your shell when you disconnect...

Previous: Daniel CorbeNext: Daniel Corbe
Message 6 of 11 in “Location of git config on Windows”
  1. Daniel CorbeAug 17, 2014
  2. Jason PyeronAug 17, 2014
  3. Erik Faye-LundAug 17, 2014
  4. Karsten BleesAug 17, 2014
  5. Daniel CorbeAug 18, 2014
  6. Erik Faye-LundAug 18, 2014
  7. Daniel CorbeAug 18, 2014
  8. Erik Faye-LundAug 18, 2014
  9. Erik Faye-LundAug 18, 2014
  10. Daniel CorbeAug 18, 2014
  11. Erik Faye-LundAug 18, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.