2

Running git config --list --show-origin on a Windows 10 machine shows me that the location of .gitconfig is in a remote location. I don't know how it ended there!

enter image description here

I tried few steps to change this from older posts. But with Git 2.30.00 I can't find some of the files or configuration that other StackOverflow Q/A mention. I want to move this to somewhere locally, either D: or my user directory.

The env file that some mention from other questions is like this in my case

export PATH="$HOME/bin:$PATH"

# Allow SSH to ask via GUI if the terminal is not usable
test -n "$SSH_ASKPASS" || {
  case "$MSYSTEM" in
  MINGW64)
    export DISPLAY=needs-to-be-defined
    export SSH_ASKPASS=/mingw64/libexec/git-core/git-gui--askpass
    ;;
  MINGW32)
    export DISPLAY=needs-to-be-defined
    export SSH_ASKPASS=/mingw32/libexec/git-core/git-gui--askpass
    ;;
  esac
}
joanis
  • 10,635
  • 14
  • 30
  • 40
arianit ax
  • 187
  • 1
  • 3
  • 13
  • Does this question help, or are those solutions also failing for you? https://stackoverflow.com/q/28690019/3216427 – joanis Jan 14 '21 at 14:28

2 Answers2

3

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

set HOME=/local/path

Git by default will use the $HOME environment variable to create the location of the global .gitconfig file.

There is also another way, without making changes to the $HOME variable, by creating an alias which overrides the $HOME variable. More information on this on the following webpage, How can I specify custom global gitconfig path?

Shaqil Ismail
  • 1,794
  • 1
  • 4
  • 5
  • where do I find the actual $HOME path? what or who sets it initially? I tried this command in git bash but it didn't change anything. $HOME shows `bash: /y/: Is a directory` – arianit ax Jan 14 '21 at 14:17
  • 2
    Many programs use the `$HOME` variable. I would not change it just for Git, there might be unintended side effects. – joanis Jan 14 '21 at 14:24
  • And yet that answer got good scores here: https://stackoverflow.com/q/28690019/3216427 so maybe it's the way to go... ? – joanis Jan 14 '21 at 14:27
  • Backtracking some more, sorry: if Git is looking for `.gitconfig` in `Y://`, `$HOME` is probably not defined correctly, so this is probably the right solution. – joanis Jan 14 '21 at 14:29
  • this must be the solution to my issue. but found out that HOME was locked to Y: from the IT – arianit ax Jan 14 '21 at 15:59
1

TL;DR It might work best to tell Windows globally where you want your HOME

Motivation

While Shaqil's answer should work for you, I expect your strange $HOME variable might cause other problems. On Windows 10, I used to have my HOME set to a network drive when that network drive was visible at boot time, because of my administrator's Windows policies. This created issues not just with Git, but also with other programs that expect to find dot files in my home directory. It also caused a serious slow down of various programs because that network drive had a huge lag when working at home over the VPN.

Solution

My solution was more global: tell Windows that my HOME directory should be local. That fixed both Git and the lag for me, and several other things.

Go to

  • Start Menu /
    • Settings /
      • Search for "variables" /
        • Pick "Edit environment variables for your account"

Then use either "Edit..." or "New..." to set

  • HOME to c:\Users\username
  • HOMEDRIVE to C:
  • HOMEPATH to \Users\username

Although these may seem redundant, some programs rely on HOME, and others on HOMEDRIVE and HOMEPATH, to decide where your HOME is, so you should keep them consistent.

Caveat

Of course, this solution is only appropriate if you want all of your applications see see your home directory on the C: drive.

joanis
  • 10,635
  • 14
  • 30
  • 40