简体   繁体   English

Pycharm 终端指向错误的 git 可执行文件 (MacOS)

[英]Pycharm terminal is pointing to the wrong git executable (MacOS)

I'm trying to use git in the Pycharm terminal, but when I type which git , I get /usr/bin/git , and when I try running git I get an error (including a stack trace):我试图在 Pycharm 终端中使用 git,但是当我输入which git ,我得到/usr/bin/git ,当我尝试运行 git 时,我得到一个错误(包括堆栈跟踪):

git: error: unable to find utility "git", not a developer tool or in PATH

However, in a normal Mac terminal, if I type which git , I get /usr/local/bin/git , and this executable runs correctly.但是,在普通的 Mac 终端中,如果我输入which git ,我会得到/usr/local/bin/git ,并且这个可执行文件可以正确运行。

How can I get the Pycharm terminal to point to the correct git?如何让 Pycharm 终端指向正确的 git? I tried updating the $PATH and changing the path to the git executable in the Pycharm preferences (and restarting Pycharm after doing this) but none of these worked.我尝试更新$PATH并在 Pycharm 首选项中更改 git 可执行文件的路径(并在执行此操作后重新启动 Pycharm),但这些都不起作用。

The issue might be because you are missing to add the file extension of executable.问题可能是因为您缺少添加可执行文件的文件扩展名。

Change your shell path in PyCharm terminal settings.在 PyCharm 终端设置中更改您的 shell 路径。 Settings are located at:设置位于:

Settings > Tools > Terminal > Application settings > shell path

In MacOs find out corresponding shell or bash executable path.在 MacOs 中找出对应的 shell 或 bash 可执行路径。 It should be in /usr/local/bin/<executable(git or bash or sh) with its extension>它应该在/usr/local/bin/<executable(git or bash or sh) with its extension>

For windows, extension is .exe :对于 Windows,扩展名为.exe

C:\\Program Files\\Git\\bin\\sh.exe or C:\\Program Files\\Git\\bin\\bash.exe C:\\Program Files\\Git\\bin\\sh.exeC:\\Program Files\\Git\\bin\\bash.exe

Reference :参考

在此处输入图片说明

PS This terminal setting is specific to a project, and you might need to change the settings for every new project. PS此终端设置特定于项目,您可能需要为每个新项目更改设置。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM