Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"/usr/local/bin/git": error=2, No such file or directory Android Studio

So I opened the GitHub Application for the Mac and I was prompted with this:

GitHub for Mac no longer installs Git

OS X 10.9 and later includes Git, so GitHub for Mac will no longer install Git as part of its command line tools.

The version of Git you have installed through GitHub for Mac is no longer supported. It's recommended that you uninstall it as soon as possible.

[ Uninstall Git Later] [ Uninstall Git Now ]

I went ahead and uninstalled Git because I was under the impression that I was supposed to (GitHub for Mac no longer installs Git message)

Now I share my Android Studio Project via Github. Whenever I try to push changes the my project or do anything I get this error message:

Can't start Git: /usr/local/bin/git Probably the path to Git executable is not valid. Fix it.

And this message:

Error running git “Cannot run program ”git": error=2 No such file or directory

I've done research but I am unable to fix it.

I entered which -a git in the terminal and I got:

/usr/local/bin/git

which is set is the Android Studio Project sync with Github.

How can I resolve this error? Why is this occurring?

like image 558
Rohit Tigga Avatar asked Jan 04 '15 00:01

Rohit Tigga


1 Answers

The reason why this is occurring is that:

You have uninstalled the Git that the Android Studio is pointing to, which was installed by Github for Mac, and was located in /usr/local/bin/git. But now you have deleted it, so the Android Studio can't find it of course. Let's call it GitHub-Git.

However, as mentioned by Github for Mac which is correct,

OS X 10.9 and later includes Git, so GitHub for Mac will no longer install Git as part of its command line tools.

It means there is another Git pre-installed in your system for OS X 10.9 and later, let's call it System-Git. You can prove it by opening your Terminal, and type in the git command, as you can see below: enter image description here

So the Git is still working!! Even after you have uninstalled your GitHub-Git. Why? Because Terminal is using the System-Git. Ok, so there's still git on your Mac, all you have to do is tell the Android Studio where the git is!

Solution!!:

  1. Find the location of System-Git. In Terminal, type in whereis git. In my case, the location of my System-Git is /usr/bin/git enter image description here
  2. In your Android Studio, go to Preferences and search for the keyword git enter image description here Here you see you got a WRONG path for the git /usr/local/bin/git, which should be /usr/bin/git. Just replace it with a right one, press Apply.

Now, everything should be working.

like image 131
Scott Zhu Avatar answered Oct 20 '22 01:10

Scott Zhu