bash 如何更改我的 Git 主文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38317134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 22:21:19  来源:igfitidea点击:

How do I change my Git home folder?

gitbashshellgithubhome-directory

提问by Tommy Saechao

How do I change my git home folder? Currently my git folder is located in my %AppData% folder. I store my projects in my C:\Projects folder. I would like my git bash to start up in my C:\Projects folder and whenever I cd to my home directory (cd ~) I want it to navigate to C:\Projects.

如何更改我的 git 主文件夹?目前我的 git 文件夹位于我的 %AppData% 文件夹中。我将项目存储在 C:\Projects 文件夹中。我希望我的 git bash 在我的 C:\Projects 文件夹中启动,并且每当我 cd 到我的主目录 (cd ~) 我希望它导航到 C:\Projects。

回答by BladeMight

Maybe this is what you want:

也许这就是你想要的:

cd /c/projects

EDIT:
if you want it to start up within this directory, then just do this in cmd(admin):

编辑:
如果您希望它在此目录中启动,则只需在 cmd(admin) 中执行此操作:

setx HOME "C:\Projects"

after this you need to restart git-bash.
To test variable enter this in git-bash:

在此之后,您需要重新启动 git-bash。
要测试变量,请在 git-bash 中输入:

echo $HOME