我已经安装了Git for Windows,但是当我尝试在命令提示符中使用Git命令时,我得到以下错误:

'git' is not recognized as an internal or external command,
operable program or batch file. 

我如何解决这个问题?


当前回答

这是因为在安装时,您已经选择了默认单选按钮,只使用“Git”和“Git bash”。如果你选择“Git和命令行工具”,这就不是问题了。

解决方案#1:因为你已经安装了Git工具,现在导航到所需的文件夹,然后右键单击并使用“Git bash here”运行相同的命令,它将正常运行。 解决方案#2:尝试重新安装Git-scm并选择正确的选项。

其他回答

安装git之前打开cmd提示符了吗?如果是,请关闭并重新打开。

如果你正在使用GitHub for Windows (GitHub的旧Git GUI不再可供下载,而不是新的基于电子的GitHub Desktop),你在下面安装了Git:

C:\Users\<YOUR USERNAME>\AppData\Local\GitHub\PortableGit_8810fd5c2c79c73adcc73fd0825f3b32fdb816e7\cmd

展开该路径,并将其添加到path。

我遇到过这个问题,在安装Git后解决了 Downloadlink: https://git-scm.com/downloads

如果你想设置为临时用途,只需执行下面的命令。

打开命令提示符< run——> CMD > . CMD 执行以下命令。 设置路径=C:\程序文件\Git\bin 输入git,就可以了。


这是有效的当前窗口/单元格,如果你将关闭命令提示符,一切都将消失。 为了永久设置,在环境变量中设置GIT。

a.按窗口+暂停键 b.单击“高级系统设置”。

c.单击“高级选项卡”下的“环境变量”。

d.编辑“路径变量”。

e.在语句末尾添加以下行。 Git; c: \ Program Files \ \ bin。

f.按“OK”!! g.打开新的命令提示符。 h.输入“git”,按“Enter”

谢谢

如果你使用的是Windows 10,请这样做:

Go to Start Start typing 'This PC' Right-click This PC, choose Properties On the left side of the window that pops up, click on Advanced System Settings Click on the Advanced tab Click on the Environmental Variables button at the bottom Down in the System Variables section, double-click Path Click the New button in the top right corner Add this path: C:\Program Files\Git\bin\ then click the enter key Add another path: C:\Program Files\Git\cmd Close & re-open the console if it's already open.

我带你经历了漫长的过程,让你接触到不同的Windows/菜单。祝你好运。