27

My Android Studio is complaining about

Can't start Git: /usr/bin/git

Probably the path to Git executable is not valid

although I can actually use git in android studio, and /usr/bin/git works in terminal.

How do I get rid of this false error

Here is my ~/.bash_profile

export PATH=/usr/bin/git:$PATH

Cœur
  • 37,241
  • 25
  • 195
  • 267
kevin0228ca
  • 479
  • 1
  • 8
  • 17
  • can you post the script? – Blackbelt May 05 '15 at 07:46
  • please see my ~/.bash_profile – kevin0228ca May 05 '15 at 07:54
  • can you open the android-studio's preferences, look for the version control, expand it, and select git. There should be something like *Path to git executable* – Blackbelt May 05 '15 at 07:59
  • /usr/bin/git, and when I test, git executed successfully. I can use git in android studio, just dunno why that error keeps appearing – kevin0228ca May 05 '15 at 08:03
  • can you post the result of `ls -l /usr/local/bin/git`. Are you on linux or mac ? – Blackbelt May 05 '15 at 08:05
  • I am on mac and I am missing git in /usr/local/bin – kevin0228ca May 05 '15 at 08:09
  • can you post the output of `ls -l /usr/bin/git`? are you running AS as administrator or normal user ? – Blackbelt May 05 '15 at 08:12
  • ls: /usr/local/bin/git: No such file or directory. I am running as normal user – kevin0228ca May 05 '15 at 08:13
  • again, `ls -l /usr/bin/git` without local – Blackbelt May 05 '15 at 08:13
  • -rwxr-xr-x 1 root wheel 14160 Sep 29 2014 /usr/bin/git – kevin0228ca May 05 '15 at 08:15
  • I solved by installing a git at /usr/local/git/bin/git, so now I have two git, then in android studio I use /usr/local/git/bin/git. If you can answer as why android studio complains about git at /usr/bin/git, although git works with the error, I accept your answer – kevin0228ca May 05 '15 at 08:32
  • `/usr/local/git/bin/git` doesn't look that good. Can you create a symlink to git in `/usr/local/bin` ? To me it looks like AS has not enough permissions to access /user/bin – Blackbelt May 05 '15 at 08:36
  • I symbol linked /usr/local/git/bin/git as /usr/local/bin/git, then in android studio I reference /usr/local/bin/git. Everything works, thank you. please write as a answer so I accept. I guess it is a bug that android studio error about git at /usr/bin, but actually could excute git at /usr/bin – kevin0228ca May 05 '15 at 08:56
  • [Refer for further clarifications](https://stackoverflow.com/questions/32661484/os-x-cant-start-git-usr-bin-git-probably-the-path-to-git-executable-is-not) – eranda.del Mar 15 '18 at 00:54

7 Answers7

57

If you're on Mac OSX, run sudo xcodebuild -license in the Terminal. It will show a wall of text. Carefully read the license ;) and keep pressing Space until you reach the end and then simply type agree and hit enter. This fixed the above error for me on Android Studio.

On some occasions even that might not fix this issue. Try running the following command in the Terminal and restart Android Studio.

sudo /usr/bin/git
Isuru
  • 30,617
  • 60
  • 187
  • 303
  • i tried but error....xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance – 최봉재 Jul 13 '17 at 04:45
  • 4
    **`sudo /usr/bin/git` + Studio Restart** worked just like charm. – iCantC Feb 11 '20 at 07:15
10

It is probably a permission issue on AS side. You could try to symlink /usr/bin/git to /user/local/bin/git and make AS pointing to the symlink.

TheLittleNaruto
  • 8,325
  • 4
  • 54
  • 73
Blackbelt
  • 156,034
  • 29
  • 297
  • 305
10

Fixed it.. There was no Xcode installed on my mac.

Installed it from command line

xcode-select --install

It will ask for prompt to install accept and install

Then try

git --version
John
  • 8,846
  • 8
  • 50
  • 85
10

In order to find the git path:

which git
DoronK
  • 4,837
  • 2
  • 32
  • 37
  • 1
    None of the selected answers solved my problem except this one. Thanks @DoronK – Abhinav Pawar Oct 19 '16 at 10:50
  • 1
    I used above command and response was /usr/local/bin/git. I updated Android Studio to the above, clicked on Test button and got the 'Git executed successfully' message. – Eric Oct 09 '17 at 17:26
7

After update Xcode to 7.0 my Android Studio complained about Git and the solution for me was go to terminal and type

 sudo /usr/bin/git

or

sudo git --version

This will show you this message:

You have not agreed to the Xcode license agreements.You must agree to both license agreements below in order to use Xcode.

at the final you have to agree the license

By typing 'agree' you are agreeing to the terms of the software license agreements.

Jorge Casariego
  • 21,948
  • 6
  • 90
  • 97
4

First you need to accept the license

xcodebuild -license accept
Alex Zaraos
  • 6,443
  • 2
  • 26
  • 21
0

In my case i downloaded an update of Xcode and didn't remember to Accept the New License Agreement/Terms and Conditions. So i just started the Xcode and Agreed to New License Agreement and it started working.

Ajji
  • 3,068
  • 2
  • 30
  • 31