This question already has an answer here:

I have this error on my Android Studio running with Mac OS 10.8.3, I've installed the github client but is not necesary...
Any help?
Thanks
Check the path registered in Settings -> Version Control -> Git
, in text box next to "Path to Git Executable
".
It should reference a local installation of git.
If the path mentioned there doesn't exist, that would explain the error message.
Use your terminal and check the following.
1) Check if you have installed git
git --version
You should see something like
git version 1.7.9.5
If not, there could be an error in Git installation
2) See if a .git
file exists in the directory you want to push to the remote repo.
cd <into your directory>
ls -altr
You should see a file with the name .git
.
This is the file that git will use to track the repo details.
Within terminal you can find your git install directory with:
git --exec-path
来源:https://stackoverflow.com/questions/20836338/error-running-gitcannot-run-program-git-error-2