简体   繁体   English

OS X - 无法启动 Git:/usr/bin/git 可能 Git 可执行文件的路径无效

[英]OS X - Can't start Git: /usr/bin/git Probably the path to Git executable is not valid

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.它为我提供了修复它的选项,它将我带到 Android Studio 中的区域以设置 git 的路径。 I see it is set to我看到它被设置为

/usr/bin/git /usr/bin/git

And I check that path, and that path is indeed the path to the git executable.我检查了那个路径,那个路径确实是 git 可执行文件的路径。 Why is Android Studio unable to start 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 身份重新运行。

You should run sudo git --version on your command line.您应该在命令行上运行sudo git --version It will ask you to agree to the git xcode license agreement, once done everything will work as before.它会要求你同意 git xcode 许可协议,一旦完成,一切都会像以前一样工作。

升级到 MacOS Sierra 时,我必须运行: xcode-select --install

You should agree explicitly to user's licence agreement.您应该明确同意用户的许可协议。

This is how you should do it:你应该这样做:

  1. Open terminal打开终端
  2. run the following command: sudo xcodebuild -license运行以下命令: sudo xcodebuild -license
  3. agree to the terms.同意条款。

That's it!就是这样! :) :)

I got this problem too, because I uninstalled my Xcode.我也遇到了这个问题,因为我卸载了我的 Xcode。

I solved it with these steps:我通过以下步骤解决了它:

  1. Type xcode-select --install in the terminal (Installs the license)在终端中输入xcode-select --install (安装许可证)

  2. Download a git and re-install it下载一个 git 并重新安装它

After this 2 steps, I can use git commands in the terminal like git or git --version .在这 2 个步骤之后,我可以在终端中使用 git 命令,如gitgit --version

But when I open the android studio, it still show the error但是当我打开android studio时,它仍然显示错误

so we need another two steps:所以我们还需要另外两个步骤:

  1. Type which git in your terminal (find out the git path)在终端中输入which git (找出 git 路径)

  2. Configure the path (you got in the step 3) in your android studio , then apply在您的 android studio 中配置路径(您在第 3 步中获得),然后应用

Just like below pic就像下图在此处输入图片说明

It works for me.这个对我有用。

use "which git" in terminal.在终端中使用“which git”。 It will provide you your git location.它将为您提供您的 git 位置。 like "/usr/local/bin/git" paste this location in popup which came after clicking "Fix it".像“/usr/local/bin/git”一样将此位置粘贴到单击“修复它”后出现的弹出窗口中。 Then click apply.然后点击应用。

在终端

sudo xcodebuild -license accept

In my situation I used "which git" in terminal.在我的情况下,我在终端中使用了“which git”。 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".它将为我提供我的 git 位置,例如“/usr/local/bin/git”而不是“/usr/bin/git”,我将此位置粘贴到单击“修复它”后出现的弹出窗口中。 Then clicked apply and it works.然后点击应用,它的工作原理。

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.所以我点击了除 Test 按钮之外的三个点并跳转到给定的路径,但没有 git 可执行文件存在。 So at below path I found git exec:所以在下面的路径我找到了 git exec:

/usr/local/git/bin/git /usr/local/git/bin/git

I hope it helps.我希望它有帮助。

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.想法表明:无法启动 Git:/user/bin/git... 我在终止时运行“which git”,我发现我的 git 保持在:/user/local/bin/git 所以我需要的是在项目设置中更改 git 的路径。 And it worked.它奏效了。

I had updated Xcode last night.我昨晚更新了Xcode。 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.我在终端中通过 sudo 以 root 身份运行 git,然后它说我没有同意 Xcode 许可条款,并允许我查看它们,然后在终端中同意。 I probably would have got the GUI version if I tried to open Xcode.如果我尝试打开 Xcode,我可能会得到 GUI 版本。

当我安装 MacOS Sierra 时,我运行了xcode-select --install并且运行良好

I my case I've changed the name of Xcode app to Xcode9 and renamed later to Xcode.我的情况我已将 Xcode 应用程序的名称更改为 Xcode9,稍后更名为 Xcode。

I needed to update my Xcode.app path.我需要更新我的 Xcode.app 路径。

After typing sudo xcode-select --switch /Applications/Xcode.app on terminal everything worked fine again在终端上输入sudo xcode-select --switch /Applications/Xcode.app一切正常

sudo xcode-select --reset在终端立即为我解决了这个问题。

I had the same problem in PhpStorm.我在 PhpStorm 中遇到了同样的问题。 This came to me after updating XCode on OS X EL Capitan.这是在 OS X EL Capitan 上更新 XCode 后想到的。 After this update I didn't open it to accept the license that was necessary for XCode and OS X. When I had accept the license the problem was resolved.在这次更新之后,我没有打开它来接受 XCode 和 OS X 所需的许可证。当我接受了许可证后,问题就解决了。

I have this issue when having two Xcode (ver.7 and ver.8) apps installed in my Mac OS Sierra.在 Mac OS Sierra 中安装了两个 Xcode(ver.7 和 ver.8)应用程序时,我遇到了这个问题。

What I do is simply open the Xcode 8, go to Preferences , select Locations in tab, and set the Command Lines Tools to Xcode 8.0 .我所做的只是打开 Xcode 8,转到Preferences ,在选项卡中选择Locations ,然后将Command Lines Tools设置为Xcode 8.0

  1. Run sudo git --version运行 sudo git --version

  2. If already Xcode is installed : Run sudo softwareupdate -ia --verbose If not : xcode-select --install sudo xcodebuild -license如果已经安装了 Xcode:运行 sudo softwareupdate -ia --verbose 如果没有:xcode-select --install sudo xcodebuild -license

  3. sudo xcode-select -switch /Library/Developer/CommandLineTools须藤 xcode-select -switch /Library/Developer/CommandLineTools

After this don't forget to re-start the system.之后不要忘记重新启动系统。 It worked for me and for sure work you you as well.它对我有用,当然对你也有用。

Download git from https://git-scm.com after download install it and then in terminal type which git you will get git path下载后从https://git-scm.com下载 git 安装它,然后在终端输入哪个 git你会得到 git 路径

Satishs-MacBook-Air:~ Pathuri$ which git Satishs-MacBook-Air:~ Pathuri$ which git

/usr/local/bin/git /usr/local/bin/git

Satishs-MacBook-Air:~ Pathuri$ Satishs-MacBook-Air:~ Pathuri$

click on apply and fit it on the pop up it will solve .单击应用并将其安装在弹出窗口中,它将解决。

If you recently installed Jetbrains Toolbox:如果您最近安装了 Jetbrains Toolbox:

Uninstall and installing through the Toolbox solved the problem for me.通过工具箱卸载和安装解决了我的问题。

只需在终端上运行“ /usr/local/bin/git ”。

首先尝试重新启动你的电脑,如果你刚刚安装了 git。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 INTELLIJ IDEA 错误:“无法启动 Git:/usr/bin/git 可能 Git 可执行文件的路径无效。修复它。” 如何修复? - INTELLIJ IDEA ERROR: "Can't start Git: /usr/bin/git Probably the path to Git executable is not valid. Fix it." How to Fix it? Windows - 无法启动 Git:Git 可执行文件的路径可能无效 - Windows- Can't start Git: Probably the path to Git executable is not valid 无法在OS X El Capitan中启动Git - Can't start Git in OS X El Capitan Mac的Git安装程序:为什么/ usr / local / git / bin在我的PATH中? - Git installer for Mac: Why is /usr/local/git/bin in my PATH? Eclipse:设置 git 可执行文件的路径 - OS X El Capitan - Eclipse: setting path to git executable - OS X El Capitan 可执行文件“git”不在路径中 - The executable “git” is not in the path 无法启动 Git 进程:无法运行程序“/usr/local/bin/git” - Failed to start Git process: Cannot run program "/usr/local/bin/git" 更新Mac OS / XCode后无法启动Git - can't start Git after updating Mac OS/XCode Git-bash 窗口:/usr/bin/bash:找不到配置文件/usr/local/etc/profile.global; 退出。” - Git-bash WIndows : /usr/bin/bash: can't find configuration file /usr/local/etc/profile.global; exiting." 小牛PHPStorm错误运行git ... / usr / bin / git - Mavericks PHPStorm error running git … /usr/bin/git
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM