Search code examples
gitwindows-10git-config

change default location of .gitconfig


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
}

Solution

  • 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?