Git Bash: Change Home Directory

The Home (~) directory in Git Bash can be changed by setting the user-level %HOME% environment variable in Windows.

This is quite safe as the %HOME% environment variable is not normally set for Windows applications, so creating it shouldn’t affect anything else.

Moreover, setting the user-level environment variable in Windows doesn’t require admin rights.

Cool Tip: How to change a default startup directory in Git Bash! Read More →

Change Home Directory in Git Bash

The easiest way to set the %HOME% environment variable for the current user is by using the built-in graphical editor for environment variables.

To start the environment variables editor – press the ⊞ Win keybutton to open the “Start” menu, type in envi and click on “Edit environment variables for your account”.

Alternately, you can set the %HOME% environment variable using the following command in Windows PowerShell:

PS C:\> [Environment]::SetEnvironmentVariable("HOME", "C:\path\to\home", "User")

Start a new session of Git Bash and run the following commands to change the current directory to the user’s %HOME% and verify the new path:

$ cd ~
$ pwd

Cool Tip: How to clear a commands history in Git Bash! Read More →

Was it useful? Share this post with the world!

3 Replies to “Git Bash: Change Home Directory”

  1. Thanks! I had all my files on D drive so it was pointless to have a home directory on a C drive.

  2. very nice ,its work fine

  3. I don’t get it. I got to “Edit environment variables for your account”, what am I supposed to do then? That is a tutorial that explains only 10% of the whole thing.

Leave a Reply