brew 安装出现 not in a git directory解决方法
本文首发于个人博客 Cyy’s Blog
转载请注明出处 https://cyyjs.top/blog/62a6b6d6e676b5000ec60c07
使用brew
安装软件有时会遇到如下错误:
fatal: not in a git directory
Error: Command failed with exit 128: git
解决方法如下:
输入brew -v
查看提示
Homebrew 3.5.1
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
Homebrew/homebrew-core
git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
Homebrew/homebrew-cask
此时再次安装软件就不会提示上述错误了。