windows 无法从命令行运行 git

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11720945/
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-09 09:44:40  来源:igfitidea点击:

Unable to run git from command line

windowsgitsymfony

提问by Rohitashv Singhal

I have installed GIT for Windows right now. And when I am running this into my symfony project to reinstall the vendors by

我现在已经为 Windows 安装了 GIT。当我将它运行到我的 symfony 项目中以通过以下方式重新安装供应商时

php bin/vendors install --reinstall

Then i am getting an error

然后我收到一个错误

git' is not recognized as internal or external command

I have set the environmental variables also as

我也将环境变量设置为

c:/programme files/git/cmd

Now what should I do? I have tried also for environmental variables

现在我该怎么办?我也试过环境变量

c:/program files/git/bin

but I am getting the same error

但我遇到了同样的错误

回答by eckes

Two possible solutions:

两种可能的解决方案:

  • My PATHhas backslashes instead of forward ones.
  • your first line contains a typo, should be c:\program files\git\cmd
  • 我的PATH有反斜杠而不是正斜杠。
  • 你的第一行包含一个错字,应该是 c:\program files\git\cmd

One more: If your path includes spaces, enclose it in quotes:

再一:如果您的路径包含空格,请将其括在引号中:

set PATH=%PATH%;"C:\Program Files\Git\cmd"

回答by axel

During Git installation, in the path environment settings chose the following one. Even I had the same problem, of git not executed on my normal Command Line, but i just reinstalled it with the setting "Run Git from the Windows Command Prompt"

在Git安装过程中,在路径环境设置中选择了以下一项。即使我有同样的问题,git 没有在我的普通命令行上执行,但我只是使用设置“从 Windows 命令提示符运行 Git”重新安装了它

enter image description here

在此处输入图片说明

回答by Darshana Ekanayake

Just open cmd and run this command:

只需打开 cmd 并运行以下命令:

set PATH=%PATH%;"C:\Program Files\Git\cmd"