8

I am running this command under windows 7:

git status

Now I am getting this error:

fatal: unable to access 'H:\/.config/git/config

I am disconnected from the network at the moment. Can I still fix this by changing the config location or creating a new config?

Pindakaas
  • 4,389
  • 16
  • 48
  • 83

3 Answers3

8

Can I still fix this by changing the config location or creating a new config?

You can simply change your environment variable HOME, in order to reference an existing local folder

set HOME=C:\local\path

In that folder, a .gitconfig can be defined in order to have a global git config file.

The msysgit/msysgit/git-cmd.bat defines it by default to:

@if not exist "%HOME%" @set HOME=%USERPROFILE%
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
5

Git will respect the HOME environment variable to determine the location of the global .gitconfig.

If asking your domain admin to reset your HOMEDRIVE and HOMEPATH variable back to your local user profile is not an option, you can simply change the HOME variable instead (which is usually unset, so there won’t be a conflict) at the top of your shell to make Git use that location.

For example, if you’re using Git Bash, you can simply add the following line to the bottom of your shell profile, located at C:\Program Files (x86)\Git\etc\profile:

export HOME="$USERPROFILE"

(I think $USERPROFILE is still left to the default even if the domain settings change your home drive. Of course, you can always specify a fixed path if that doesn’t work)

If you are using other shells, you can do similar things, for example in PowerShell:

$env:HOME = $env:USERPROFILE # or = 'C:\Users\poke\'

Of course, since the variable is unset by default, you could also set it at Windows level in your system configuration. That way, every program would use it automatically.

Afterwards, all Git commands will automatically look at $HOME\.gitconfig.

poke
  • 369,085
  • 72
  • 557
  • 602
-4

You need to specify the config file location using git config and the -f option.

git config -f your_config_file
dust
  • 502
  • 6
  • 19