我已经安装了Git for Windows,但是当我尝试在命令提示符中使用Git命令时,我得到以下错误:
'git' is not recognized as an internal or external command,
operable program or batch file.
我如何解决这个问题?
我已经安装了Git for Windows,但是当我尝试在命令提示符中使用Git命令时,我得到以下错误:
'git' is not recognized as an internal or external command,
operable program or batch file.
我如何解决这个问题?
当前回答
如果你正在使用GitHub for Windows (GitHub的旧Git GUI不再可供下载,而不是新的基于电子的GitHub Desktop),你在下面安装了Git:
C:\Users\<YOUR USERNAME>\AppData\Local\GitHub\PortableGit_8810fd5c2c79c73adcc73fd0825f3b32fdb816e7\cmd
展开该路径,并将其添加到path。
其他回答
检查Bit Locker是否已启用!我遇到了类似的问题,我的GIT在cmd中工作正常。但是在快速重启后,它不起作用,我得到了如上所述的错误。
所以我必须解锁比特锁,因为我已经在硬盘卷(:E)中安装了GIT,这是由比特锁加密的。
这对我很有帮助: 我设置 C:\Program Files (x86)\Git\cmd 环境变量的路径。
开始->所有程序->Git->Git Bash
带你直接到Git Shell。
如果你使用的是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并选择正确的选项。