我已经安装了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.
我如何解决这个问题?
当前回答
如果你使用的是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之前打开cmd提示符了吗?如果是,请关闭并重新打开。
搜索GitHubDesktop\app-2.5.0\resources\app\git\cmd 打开文件 复制文件位置。 寻找环境。 打开编辑系统环境变量。 打开环境变量。 在用户变量上双击Path。 点击新建 过去的 好吧 系统变量的开放路径。 新建,经过add \(反斜杠),然后OK 搜索GitHubDesktop\app-2.5.0\resources\app\git\usr\bin\ 14再次复制“Address”,重复步骤4至12的粘贴操作。
这是因为在安装时,您已经选择了默认单选按钮,只使用“Git”和“Git bash”。如果你选择“Git和命令行工具”,这就不是问题了。
解决方案#1:因为你已经安装了Git工具,现在导航到所需的文件夹,然后右键单击并使用“Git bash here”运行相同的命令,它将正常运行。 解决方案#2:尝试重新安装Git-scm并选择正确的选项。
我通过将Target框架更改为. net 6.0来解决这个问题。
要做到这一点,请遵循这条路径。
解决方案资源管理器->右键单击项目->属性
然后尝试改变框架。
如果你得到这个错误,你可能没有在你的系统中安装git。
在此下载:
https://git-scm.com/downloads
安装它。
如果您使用的是Windows,现在将看到一个C:\Program Files\Git文件夹。
打开一个新的命令提示符窗口,并尝试再次运行git命令。