Friday, December 23, 2011

Incorrect $HOME using Git Bash on Windows

I had installed Git Bash and was trying to push a set of commits back to github.  This was failing because git was looking for my ssh keys in the wrong location.  It should have been looking in /c/Users/myusername/.ssh but instead was looking in /c/Windows/SysWOW64/config/systemprofile/.ssh.  I found out it was due to the $HOME environment variable.

I looked in my environment variables and saw %HOME% was set to %USERPROFILE% in the system properties.  In git bash, $USERPROFILE was set to /c/Users/myusername but $HOME was set to /c/Windows/SysWOW64/config/systemprofile.  Strange.  I then decided to try setting a %HOME% environment variable in the user variable on Windows.  I went back into git bash and $HOME was set correctly.

Hope this helps someone.