我更新了最新的操作系统,和/或重新启动了我的计算机(每次重大更新都会发生这种情况,但这次我所做的只是在2022-09-13年重新启动我的计算机)

今天早上,我在MacBook pro的命令行中导航到我的工作代码库,在存储库中键入“gitstatus”,收到一个错误:

(2022年9月,这个错误大不相同,但我没有捕捉到它)

xcrun:错误:无效的活动开发人员路径(/Library/developer/CommandLineTools),在以下位置缺少xcrun:/Librari/developer/CommandLineTools/usr/bin/xcrun

git不起作用!

如何修复git和命令行工具?


当前回答

M1的后续工作

ProductName:    macOS
ProductVersion: 11.2.1
BuildVersion:   20D74

% xcode-select --install

同意“条款和条件”提示,成功后将返回以下消息。

% xcode-select: note: install requested for command line developer tools

其他回答

对我来说,有效的方法如下:

sudo xcode-select --reset

然后像@High6的回答一样:

sudo xcodebuild -license

这将显示一个许可证,我认为它是某种Xcode许可证。使用空格(或鼠标)滚动到底部,然后点击同意。

这就是我在MacOS Mojave v 10.14中所做的工作。

凭借之前的应用程序开发经验,我可以放心地说,与苹果一起交付的git版本总是会带来问题。所以,你越早摆脱苹果吉特越好,所以我可以建议:

brew uninstall git
brew update
brew install git

# which git
/usr/local/bin/git

从Mojave更新到Big Sur,并得到相同的错误:命令

xcode-select --install

工作得很有魅力

M1的后续工作

ProductName:    macOS
ProductVersion: 11.2.1
BuildVersion:   20D74

% xcode-select --install

同意“条款和条件”提示,成功后将返回以下消息。

% xcode-select: note: install requested for command line developer tools

对我来说,这发生在Mac OS更新到Mojave之后,git在Intellij中无法运行

解决方案:-转到“设置”,然后选择“文件”|“设置”|“版本控制”|“Git”,然后编辑“Git可执行文件的路径”字段,该字段为/usr/local/bin/Git