Quick Tip: Changing Default Directory of Git Bash

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):

Press ‘i’ to go into ‘Insert’ mode. Type in the following (change <my/desired/home/dir> to your new home directory).

Your .bashrc should look something like this:

Adding .bashrc to Git Bash

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.

9 Responses

    1. 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.

Leave a Reply