Solution without having to change Windows HOME variable
OS: Windows 10
git version: 2.27.0.windows.1
I use portable version of Git, so all my config files are on my pen-drive(E:). This is what worked for me:
.gitconfig
and other bash files in E, so I created a folder called home where I want them all in.mkdir home
HOME="E:\git\home"
Now it no longer searches in the C:\Users<username> directory for .gitconfig but only looks in your set path above.
$ git config --global --list
fatal: unable to read config file 'E:/git/home/.gitconfig': No such file or directory
It gave an error because there isn't a .gitconfig file there yet. This is just to demonstrate that we have successfully changed the location of the .gitconfig file without changing the HOME directory in Windows.