适用于 Windows 的 Git 不执行我的 .bashrc 文件 [英] Git for Windows doesn't execute my .bashrc file
问题描述
我刚刚在 Windows 7 上安装了适用于 Windows 2.5.0 的 Git,当我运行 Git Bash 时,我的 .bashrc
文件似乎没有被执行.
I've just installed Git for Windows 2.5.0 on Windows 7, and it appears that my .bashrc
file is not being executed when I run Git Bash.
我是这样创建文件的:
Administrator@HintTech-Dev MINGW64 /
$ pwd
/
Administrator@HintTech-Dev MINGW64 /
$ cd ~
Administrator@HintTech-Dev MINGW64 ~
$ pwd
/c/Users/Administrator
Administrator@HintTech-Dev MINGW64 ~
$ touch .bashrc
Administrator@HintTech-Dev MINGW64 ~
$ vi .bashrc
[... I insert the line "ZZZTESTVAR=234" (without the quotes) into the file in vim ...]
Administrator@HintTech-Dev MINGW64 ~
$ exit
然而,当我下次运行 Git Bash 时:
Yet, when I next run Git Bash:
Administrator@HintTech-Dev MINGW64 /
$ set | grep ZZZ
Administrator@HintTech-Dev MINGW64 /
$ cat ~/.bashrc
ZZZTESTVAR=234
Administrator@HintTech-Dev MINGW64 /
$ ZZZTESTVAR=234
Administrator@HintTech-Dev MINGW64 /
$ set | grep ZZZ
ZZZTESTVAR=234
Administrator@HintTech-Dev MINGW64 /
$
为什么我的 .bashrc
没有运行?它似乎在正确的位置并具有正确的权限.
Why isn't my .bashrc
being run? It seems to be in the right place and have the right permissions.
推荐答案
好的,我找到了问题所在.很简单,最新的 Git for Windows 2.5.0 (mintty) 使用的 bash 终端不需要读取 .bashrc
- 它读取的是 .bash_profile
.因此,您可以在 .bash_profile
中设置您的环境和/或将此代码放在开头以读取 .bashrc
:
OK, I found out the problem. Quite simply, the bash terminal used by the latest Git for Windows 2.5.0 (mintty) doesn't bother to read .bashrc
- it reads .bash_profile
. So you can set up your environment in .bash_profile
and/or put this code at the start to read .bashrc
:
if [ -f ~/.bashrc ]
then
. ~/.bashrc
fi
这篇关于适用于 Windows 的 Git 不执行我的 .bashrc 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!