Skip to content

How to change the ~ default home directory? | 如何更改 ~ 缺省的主目录? #2993

Answered by DRSDavidSoft
DOSforever asked this question in Q&A
Discussion options

You must be logged in to vote

English Response:
In a Unix-like shell (e.g., bash), the ~ (tilde) symbol is a shortcut for the current user’s home directory, which typically maps to $HOME. In Git-for-Windows, this defaults to your Windows user profile directory (e.g., C:\Users\YourUsername). If you want cd ~ to point to a different directory without modifying USERPROFILE or HOMEPATH, you can:

  1. Override the HOME variable in your shell session:
    Run export HOME=/your/custom/path in bash. This changes ~ temporarily for the current session.

  2. Permanently configure HOME in your bash profile:
    Add export HOME=/your/custom/path to ~/.bash_profile or ~/.bashrc. This ensures ~ points to your desired directory every time you star…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by DOSforever
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants