windows 'git' 不被识别为内部或外部命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30352591/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:04:43  来源:igfitidea点击:

'git' is not recognized as an internal or external command

windowsgit

提问by venugopal

I created Android Project in Android Studio, now that I would like to push it into my repository.

我在 Android Studio 中创建了 Android 项目,现在我想将它推送到我的存储库中。

When I enter the following command in Android Studio terminal:

当我在 Android Studio 终端中输入以下命令时:

git remote add origin https://..........

The following error is returned:

返回以下错误:

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

How can I fix this?

我怎样才能解决这个问题?

回答by Mittal Patel

If "git" is not installed then you need to install git and while installation select option 'Use Git from the Windows Command Prompt'.

如果未安装“git”,则需要安装 git 并在安装时选择“从 Windows 命令提示符使用 Git”选项。

If "git" is installed but still you are getting "git is not recognized as an internal or external command" error then you need to set PATH variable to point to git executable. To do that follow the steps below:

如果安装了“git”但仍然收到“git 未被识别为内部或外部命令”错误,那么您需要将 PATH 变量设置为指向 git 可执行文件。要做到这一点,请按照以下步骤操作:

  • Open My Computer, right click and select Properties
  • On this window, click on Advanced System Settings link which will open System Properties popup.
  • In that popup (under Advanced tab), click on Environment Variables which will open Environment Variables popup.
  • In that popup, select Path and click on Edit, which will open Edit Environment Variable popup Click on Edit to open Edit Environment Variable popup
  • From that popup window, click on Browse and browse to the git installation directory. Mostly it would be "C:\Program Files (x86)\Git\bin", select the directory and click Ok on all opened popups.
  • 打开我的电脑,右击选择属性
  • 在此窗口中,单击高级系统设置链接,这将打开系统属性弹出窗口。
  • 在该弹出窗口中(在“高级”选项卡下),单击“环境变量”,这将打开“环境变量”弹出窗口。
  • 在该弹出窗口中,选择 Path 并单击 Edit,这将打开 Edit Environment Variable 弹出窗口 单击编辑打开编辑环境变量弹出窗口
  • 从该弹出窗口中,单击 Browse 并浏览到 git 安装目录。大多数情况下,它是“C:\Program Files (x86)\Git\bin”,选择目录并在所有打开的弹出窗口中单击“确定”。

You will need to close command prompt and open again. Git command should work now!

您将需要关闭命令提示符并再次打开。Git 命令现在应该可以工作了!

回答by Nick Volynkin

Most probably Git is not installed on your machine (or installed incorrectly). Open this linkto download an installer. It should do the job for you.

很可能 Git 没有安装在您的机器上(或安装不正确)。打开此链接以下载安装程序。它应该为您完成这项工作。

There are also other waysto install Git on Windows.

还有其他方法可以在 Windows 上安装 Git。

回答by pblead26

When you install Git, you must select the option 'run Git from the Windows command prompt'?

安装 Git 时,是否必须选择“从 Windows 命令提示符运行 Git”选项?

Download the latest version of the Git from here : http://git-scm.com/downloadand try again!

从这里下载最新版本的 Git:http: //git-scm.com/download 并重试!