卸载Xcode(使用Android Studio)后,如何在Mac上继续使用Git?

Ser*_*o76 1 git xcode github-for-mac android-studio

我已经在Mac上安装了Git。当我在终端中执行“ whereis”操作时,路线为:

/usr/bin/git
Run Code Online (Sandbox Code Playgroud)

我使用Android Studio和GitHub桌面客户端,到目前为止没有任何问题。

以前我已经安装了Xcode,但是一周前我将其卸载了。从那时起,Android Studio不会检测到Git,我收到以下错误消息:

xcrun:错误:活动的开发人员路径(“ /Volumes/Vega/Applications/Xcode.app/Contents/Developer”)不存在,用于xcode-select --switch path/to/Xcode.app指定您希望用于命令行开发人员工具的Xcode(或参见 参考资料man xcode-select

Android Studio显示了指向Git的相同可执行路径,指示了终端(/usr/bin/git),但是当我单击“测试”按钮时,它也会显示相同的错误。

我在终端上对Git的处理不太好,始终使用桌面客户​​端。

卸载Xcode后,我该怎么做才能继续在Android Studio(或其他任何地方)上使用Git?

我搜索了信息,但无法解决。

小智 6

sudo xcode-select --reset

如果已经安装了命令行工具,会将您的路径重置为默认值。


Mar*_*sky 5

如果命令sudo xcode-select --resetxcode-select --install对您不起作用,并且您不想安装xcode,则只需通过brew以下命令手动重新安装git :

brew reinstall git
Run Code Online (Sandbox Code Playgroud)

并打开新的终端会话

为我工作

  • 这应该是公认的答案。无需13GB的Xcode即可安装git。 (3认同)
  • `xcode-selet --install` 然后 `sudo Xcode-select --reset` 足以让我在卸载 Xcode 后修复 git (2认同)