OS X - 无法启动 Git:/usr/bin/git 可能 Git 可执行文件的路径无效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32661484/
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
OS X - Can't start Git: /usr/bin/git Probably the path to Git executable is not valid
提问by BeniaminoBaggins
I get this error in Android Studio:
我在 Android Studio 中收到此错误:
Can't start Git: /usr/bin/git Probably the path to Git executable is not valid.
无法启动 Git:/usr/bin/git 可能是 Git 可执行文件的路径无效。
It gives me an option to fix it, where it takes me to the area in Android Studio to set the path to git. I see it is set to
它为我提供了修复它的选项,它将我带到 Android Studio 中的区域以设置 git 的路径。我看到它被设置为
/usr/bin/git
/usr/bin/git
And I check that path, and that path is indeed the path to the git executable. Why is Android Studio unable to start git?
我检查了那个路径,那个路径确实是 git 可执行文件的路径。为什么Android Studio 无法启动git?
EDIT: When I try to use git commands in the Android Studio terminal it says:
编辑:当我尝试在 Android Studio 终端中使用 git 命令时,它说:
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
同意 Xcode/iOS 许可证需要管理员权限,请通过 sudo 以 root 身份重新运行。
回答by Yaron Recher
You should run sudo git --version
on your command line.
It will ask you to agree to the git xcode license agreement, once done everything will work as before.
您应该sudo git --version
在命令行上运行。它会要求你同意 git xcode 许可协议,一旦完成,一切都会像以前一样工作。
回答by Justin
When upgrading to MacOS Sierra I had to run: xcode-select --install
升级到 MacOS Sierra 时,我必须运行: xcode-select --install
回答by cyber101
You should agree explicitly to user's licence agreement.
您应该明确同意用户的许可协议。
This is how you should do it:
你应该这样做:
- Open terminal
- run the following command:
sudo xcodebuild -license
- agree to the terms.
- 打开终端
- 运行以下命令:
sudo xcodebuild -license
- 同意条款。
That's it! :)
就是这样!:)
回答by Jeffery Ma
I got this problem too, because I uninstalled my Xcode.
我也遇到了这个问题,因为我卸载了我的 Xcode。
I solved it with these steps:
我通过以下步骤解决了它:
Type
xcode-select --install
in the terminal (Installs the license)Download a git and re-install it
键入
xcode-select --install
在终端(安装许可证)下载一个 git 并重新安装它
After this 2 steps, I can use git commands in the terminal like git
or git --version
.
在这两个步骤之后,我可以在终端中使用 git 命令,例如git
或git --version
。
But when I open the android studio, it still show the error
但是当我打开android studio时,它仍然显示错误
so we need another two steps:
所以我们还需要另外两个步骤:
Type
which git
in your terminal (find out the git path)Configure the path (you got in the step 3) in your android studio , then apply
输入
which git
您的终端(找出git的路径)在您的 android studio 中配置路径(您在第 3 步中获得),然后应用
It works for me.
这个对我有用。
回答by Sajid Zeb
use "which git" in terminal. It will provide you your git location. like "/usr/local/bin/git" paste this location in popup which came after clicking "Fix it". Then click apply.
在终端中使用“which git”。它将为您提供您的 git 位置。像“/usr/local/bin/git”一样将此位置粘贴到单击“修复它”后出现的弹出窗口中。然后点击应用。
回答by Kleyton Menezes
In terminal
在终端
sudo xcodebuild -license accept
回答by Cüneyt
In my situation I used "which git" in terminal. It will provide me my git location like "/usr/local/bin/git" instead of "/usr/bin/git" I pasted this location in popup which came after clicking "Fix it". Then clicked apply and it works.
在我的情况下,我在终端中使用了“which git”。它将为我提供我的 git 位置,例如“/usr/local/bin/git”而不是“/usr/bin/git”,我将此位置粘贴到单击“修复它”后出现的弹出窗口中。然后点击应用,它的工作原理。
回答by Varsha P
I tried "/usr/local/bin/git" path and clicked "Test" button but was getting error.
我尝试了“/usr/local/bin/git”路径并单击“测试”按钮但出现错误。
so I clicked on three dots besides Test button and jumped to the given path but there was no git executable present. So at below path I found git exec:
所以我点击了除 Test 按钮之外的三个点并跳转到给定的路径,但没有 git 可执行文件存在。所以在下面的路径我找到了 git exec:
/usr/local/git/bin/git
/usr/local/git/bin/git
I hope it helps.
我希望它有帮助。
回答by Richard
I met a same problem. Idea indicate that: Can't start Git: /user/bin/git... And I run "which git" on terminate and I found that my git stay on: /user/local/bin/git So what I need is change git's path on project setting. And it worked.
我遇到了同样的问题。想法表明:无法启动 Git:/user/bin/git... 我在终止时运行“which git”,我发现我的 git 保持在:/user/local/bin/git 所以我需要的是在项目设置中更改 git 的路径。它奏效了。
回答by BeniaminoBaggins
I had updated Xcode last night. I ran git as root via sudo in the terminal and then it said I have not agreed to the Xcode licence terms, and allowed me to view them and then agree in the terminal. I probably would have got the GUI version if I tried to open Xcode.
我昨晚更新了Xcode。我在终端中通过 sudo 以 root 身份运行 git,然后它说我没有同意 Xcode 许可条款,并允许我查看它们,然后在终端中同意。如果我尝试打开 Xcode,我可能会得到 GUI 版本。