'Error running git in PyCharm after recent update

I have this "Error Running Git" message when trying to clone from GitHub in PyCharm, it says "cannot run program "/usr/local/bin/git: error=2, no such file or directory". I guess I need to configure "path to git executable"? But I don't know how, I'm very new to using git. And this only occurs lately, after I updated the PyCharm lately.

Updated: After put in the new path, I got an new error:

enter image description here



Solution 1:[1]

This means that the XCode Command Line Tools haven't been installed. Open and terminal window and type:

xcode-select --install

This will trigger the install and clear up the problem.

(thank you to @totalhorizon: https://tips.tutorialhorizon.com/2015/10/01/xcrun-error-invalid-active-developer-path-library-developer-commandline-tools-missing-xcrun)

Solution 2:[2]

[Not tested]

Looks like this happens because of bad xcrun path. Try this:


1. Find where is xcrun located using which xcrun and add it to the given path: ln -s [path from which crun]/Library/Developer/CommandLineTools/usr/bin/xcrun


2. Reinstall developer directory manager using xcode-select --install.

Solution 3:[3]

Press Ctrl+Alt+S then type "git". This will bring you to the git settings. Here you can specify the correct path to the git executable.

enter image description here

This screenshot is from IntelliJ; you should see something very similar in PyCharm.

Solution 4:[4]

My IDEs (PyCharm, GoLand and IntelliJ) were working fine. In order to build a source code from GitHub, I had to install Xcode. However, since my company had not updated our Macs to latest OS, (We are on Catalina while the latest is Big Sur), I had to install an older (compatible) version of Xcode.

The installation of older Xcode resulted in overwriting of git to an older version. Running xcode-select --install had no effect since the OS itself was older. All I'd get is:

mac t2 % sudo xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

Even running sudo softwareupdate -ia returned:

mac t2 % sudo softwareupdate -ia
Software Update Tool

Finding available software
No updates are available.

To work around this, I used brew to install git for me. Ran, brew install git and it updated a whole bunch of things along with installing latest version of git. Restarted my IDEs and none of them complained anymore.

Solution 5:[5]

I solve this problem by the following 3 steps:

  1. run in terminal: xcode-select --install;
  2. download git (https://git-scm.com/download/mac) and install it;
  3. set the git path in Pycharm to: /usr/local/git/bin/git

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 seayak
Solution 2
Solution 3 Cani
Solution 4 displayName
Solution 5 Xiong-Hui Chen