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

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

我如何解决这个问题?


当前回答

确保正确的git路径添加到路径变量 环境变量。例如- C:\Program Files C:\Program Files (x86)\Git\cmd。它可以是不同的 具体情况取决于安装git的位置。 如果它不工作,尝试重新启动命令提示符,使其读取 更新的环境变量。 如果它仍然不工作,尝试重新启动你的机器强制命令 提示读取更新的环境变量。

其他回答

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

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

我遇到了这个问题,当你安装git时,你必须选择正确的路径,我的意思是,它应该是你在git Bash中写git(代码)的相同路径…例如,如果您的路径是c:\Users\username,则必须将git安装在相同的路径(c:\Users\username)。这两条路径不应该不同

哟!我在这方面有很多问题。似乎Github带来了自己的控制台,你需要在你的驱动器中寻找。我最终通过以下方法运行了它:

按下开始键。 搜索“GitHub”(不带引号) 右键点击“GitHub”,选择“打开文件位置”

*这将打开*

C:\Users\UserName\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\GitHub, Inc

username是你电脑的用户名

找一个叫“Git Shell”的程序。双击它。

这将打开一个PowerShell命令提示符。然后你就可以在上面正常运行git命令了。

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