My Macbook had a hardware failure recently and I ended up working on a Windows XP machine briefly. While configuring my development environment, I set up my working directory outside my Windows user profile directory (
C:\Documents and Settings\Greg). How did Microsoft ever think ‘Document and Settings’ was a good path for user profiles?!
I needed to pull my company repository down from Github. msysgit was already installed. When starting
gitbash to work with git, the default starting directory is
%HOMEDRIVE%%HOMEPATH%, this translates to
/c/Documents and Settings/Greg and not my working directory
/c/greg/workspace/repo. Being a Linux/Mac guy I thought I might be able change my
$HOME variable location but you won’t find a
/etc/passwd file in msysgit’s emulation layer, and it won’t read
.bash_profile or similar file early enough.
We have to do this the Windows way. Create a new environment variable and update the
gitbash shortcut startup directory.
You can define a new environment variable by right clicking My Computer, select Properties and click the Advanced tab. At the bottom of this tab you’ll see a ‘Environment Variables’ button. Click this and define a new variable,
HOME, with the value set to your working directory (in my case
Now we can update our gitbash shortcut and use
%HOME% to set the start up directory. Right click your gitbash shortcut and click Properties. Change the value of ‘Start in:’ field to
%HOME%. Click OK.
Now when you open
gitbash you’ll start in your working directory, no need to
cd to it everytime.
You can skip to the end and leave a response. Pinging is currently not allowed.