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

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

我如何解决这个问题?


当前回答

如果你使用的是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/菜单。祝你好运。

其他回答

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

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

Go to My Computer => Local Disk(C:) => Program Files(x86) => Git => cmd Right Click the git => Select Properties Under the location Copy the text eg - C:\Program Files (x86)\Git\cmd Come back to the Desktop Right-click My Computer Select property Open Advanced Click Environment Variables In the System variables Find the Variable call Path Click the variable Click the Edit Button Select the Variable value Text Box . Go to the edge of the text and put semicolon(;) Then Right-click and press Paste Press Ok

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

只是想补充一下阿比森的答案。 如果任何人使用非管理员帐户,您可以创建一个“本地”变量,而不是允许访问标准/有限帐户的“系统”变量。 在“环境变量”窗口中: 1)在“User variables for…”部分选择“New…”按钮。 2)将“变量名称:”设置为“path”,将“变量值:”设置为“[your-git-path]”(通常在C:\Program Files (x86)\Git\ bin中找到)。 3)单击“确定”。

检查Bit Locker是否已启用!我遇到了类似的问题,我的GIT在cmd中工作正常。但是在快速重启后,它不起作用,我得到了如上所述的错误。

所以我必须解锁比特锁,因为我已经在硬盘卷(:E)中安装了GIT,这是由比特锁加密的。