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

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

我已经将Xcode版本更新到7.3。1.when我使用'git status',我发现一个错误!如下:

$git status
sh: line 1:  1601 Segmentation fault: 11  /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk / -find git 2> /dev/null
git: error: unable to find utility "git", not a developer tool or in PATH

谢谢先进!

最好的解决方案是下载并安装它 - 即使您假设它已经安装:https://git-scm.com/download/mac

我遇到了同样的问题 -- 我退出了我的 bash 会话(关闭了终端)并启动了一个新会话并修复了它。

升级到 High Sierra 和 XCode 到 9 时也发生了这种情况。此序列已修复它。

xcode-select --install
sudo xcode-select -s /Library/Developer/CommandLineTools

https://davidwalsh.name/fix-git-high-sierra-upgrade 上找到了这个答案 (文章和评论。)

对我来说,我不得不卸载并重新安装我所有的 brew 应用程序,如记录 here

brew list -1 > brew.txt # list out all installed packages
brew list -1 | xargs brew rm --force # remove all installed packages
brew install $(cat brew.txt | tr '\n' ' ') # install all previously installed packages

None 以上解决方案为我解决了这个问题,实际上我不得不重新启动我的计算机来解决它。这是一个奇怪的错误。

我在升级到 Big Sur 后遇到了同样的问题。我通过 运行 执行以下命令解决了这个问题:

sudo xcode-select -switch /Library/Developer/CommandLineTools

P.S。我不需要 运行 这个命令:xcode-select --install