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

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

我如何解决这个问题?


当前回答

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

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

其他回答

搜索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的粘贴操作。

;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd

在环境变量中添加上述路径

注意:路径可能不同,但你应该同时添加bin和CMD

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

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

我通过将Target框架更改为. net 6.0来解决这个问题。

要做到这一点,请遵循这条路径。

解决方案资源管理器->右键单击项目->属性

然后尝试改变框架。