Windows 上的 git 和系统变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4077985/
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
git and system variables on Windows
提问by Kiwi
I'm getting the infamous "'git' is not recognized as an internal or external command, operable program or batch file" after installing msysgit for Windows.
在为 Windows 安装 msysgit 后,我得到了臭名昭著的“'git' 未被识别为内部或外部命令、可操作程序或批处理文件”。
This is not the first time something like this happens; it happened when I tried to set up Python, too, but back then, I found the relevant directory to point my python
system variable to, after which it worked.
这不是第一次发生这样的事情;当我尝试设置 Python 时也发生了这种情况,但当时我找到了相关目录来指向我的python
系统变量,之后它就可以工作了。
I've tried different git directories, but I haven't had any luck setting up a system variable for git
.
我尝试了不同的 git 目录,但我没有为 .git 设置系统变量git
。
Does anyone know the location of the directory I have to point Windows to in order to understand the git
system variable in the command prompt?
有谁知道我必须将 Windows 指向的目录的位置,以便了解git
命令提示符中的系统变量?
回答by VonC
Strange: the only thing I need to make sure after a msysgit installation is for my PATH
to reference the cmd
directory of said msysgit installation.
奇怪的是:在 msysgit 安装后我唯一需要确保的是让我PATH
引用cmd
所述 msysgit 安装的目录。
By default:
默认情况下:
C:\Program Files\Git\cmd
It contains the git.cmd
script which will call the right executable.
它包含git.cmd
将调用正确的可执行文件的脚本。
回答by álvaro González
Restart Windows. It's the only way to make sure that changes to PATH environmental variable are taken into account by all programs.
重新启动 Windows。这是确保所有程序都考虑到对 PATH 环境变量的更改的唯一方法。