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 →