Mac系统使用homebrew安装组件时报错--fatal: not in a git directory Error: Command failed with exit 128: git


报错

使用brew安装wget时报错

fatal: not in a git directory
Error: Command failed with exit 128: git

解决办法

brew -v 查看会有两个提示,提示用户设置 homebrew-cask 和 homebrew-core 的文件路径为设置为safe.directory, 如下提示:

Homebrew 3.4.10-54-g987e688
fatal: unsafe repository ('/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core' is owned by someone else)
To add an exception for this directory, call:

    git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
Homebrew/homebrew-core (no Git repository)
fatal: unsafe repository ('/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask' is owned by someone else)
To add an exception for this directory, call:

    git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
Homebrew/homebrew-cask (no Git repository)

执行命令:

git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask

完成之后再次使用brew命令安装,即可成功

brew install wget

相关