Git doesn't work on MacOS Catalina: "xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing"

Git doesn't work on MacOS Catalina: "xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing"

升级到 MacOS X 10.15 Catalina 后,我无法在我的 shell:

中 运行 任何 git 命令

The default interactive shell is now zsh.

To update your account to use zsh, please run chsh -s /bin/zsh.

For more details, please visit https://support.apple.com/kb/HT208050.

~ | git

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

我认为我的 shell 有问题,所以我按照说明将默认 Mac OS shell 改回 bash,使用 GUI 并使用命令行:

chsh -s /bin/bash

我也重启了电脑。但是,我仍然看到相同的消息,即使 echo "$SHELL" 输出 /bin/bash

您需要重新安装命令行工具:

$ xcode-select --install