Git for Windows opens bash in the the user profile directory per default and I wanted to change it to the directory with my Github projects instead. I had to try a couple of approaches before finding the solution.
The first approach I tried was setting the $HOME environment variable. There are a couple different ways of doing this (like messing around with the etc/profile file) but easiest for me was using Windows’ environment variables as Git for Windows/msysgit has access to them. The Home directory for msysgit is set to the Windows environment variable %USERPROFILE% if no $HOME variable exists. So just create a $HOME environment variable in Windows (see screenshot below) and msysgit bash will use that as the default. Now you can use the command cd $HOME to go directly to your new home directory.
But msysgit still opens up in my user profile directory…
Unfortunately, this does not help with the startup directory problem. The solution is actually really simple. Right-click on the msysgit shortcut and in the Start in field, enter your desired startup directory. Easy if you know how.
- Git for Windows tip: Setting shell aliases with msysgit (danlimerick.wordpress.com)
- Git for Windows tip: setting an editor (danlimerick.wordpress.com)
- Git for Window tip: Use P4Merge as mergetool (danlimerick.wordpress.com)