I don’t know why this gave me so much trouble, but it did. When I installed Git for Windows, the default, Bash-like Windows terminal for git, it insisted that its home directory was /s (nowhere near my Documents folder in windows).
Here is a quick tip to make Git Bash change its home directory automatically (so you don’t have to cd /blah/blah/blah every time you open it).
Open your Git for Windows client. Use vim to create a .bashrc file (this file gets automatically run every time the terminal is open):
vim .bashrc
Press ‘i’ to go into ‘Insert’ mode. Type in the following (change <my/desired/home/dir> to your new home directory).
moveHome() { cd /c/<my/desired/home/dir>; } moveHome export HOME=/c/<my/desired/home/dir>
Your .bashrc should look something like this:
Press ‘esc’ to exit “Insert” mode. Type “:wq” and press ‘enter’ to save and exit. Now, reload your Git terminal window, and you should be in a new home directory!
EDIT (12/9/14): Added export line to .bashrc file to update environment variable.
didn’t work for me =/
Sorry to hear that. Did you make sure the home directory was typed out exactly as you intended (e.g. double check it in something like Windows Explorer)? I’ve done this trick a few times now, and it still works for me.
didn’t work for me either.
Now it shows line 1: syntax error near unexpected token `{cd’
The space between { and ‘cd …’ is necessary. For some reason, the script won’t work without it.
It worked for me fine. Windows 10.
Good, thanks! Really helpful. But anyway, it is not necessary to use vim 🙂
True, but easy enough to do from within Git Bash 🙂
Worked like a champ!
Thanks, it worked fine.
Thanks! It worked.
Glad it helped!
I’m late to the game, but why not:
export HOME=/c/
cd
I suppose that will work, too. More than one way to skin a cat 🙂
Worked for me on Windows10. Thanks a ton! Cheers!
Worked on Win10, thanks!
Did not work for me…
Sorry to hear that. Did you make sure the home directory was typed out exactly as you intended (e.g. double check it in something like Windows Explorer)? I’ve done this trick a few times now, and it still works for me.
Wonder is have a space in the file name will keep this from working? Where would you put the quotation marks?
To work with spaces in the path, you need to enclose the whole path in single (‘) or double (“) quotation marks:
‘/c/Program Files/Something’
“/c/Program Files/Something”
You can also use the backslash (\) character to escape the space character:
/c/Program\ Files/Something
I misunderstood your final Vim command. For posterity (and those with high DPI monitors) that’s a colon “:” followed by “wq”. Than