M1 Homebrew 的路径是 "/opt/Homebrew/"
brew安装工具时报错git路径不安全
fatal: not in a git directory
在执行
brew -v
命令时:
xxMacBook-Pro ~ % brew -v
Homebrew 3.4.1
fatal: unsafe repository ('/opt/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 /opt/homebrew/Library/Taps/homebrew/homebrew-core
Homebrew/homebrew-core (no Git repository)
fatal: unsafe repository ('/opt/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 /opt/homebrew/Library/Taps/homebrew/homebrew-cask
Homebrew/homebrew-cask (no Git repository)
解决方法:
分别执行以下命令,添加安全路径
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
验证:
brew -v
Homebrew/homebrew-core (git revision 74d95ce5939; last commit 2023-05-25)
Homebrew/homebrew-cask (git revision fbcbfbdf73; last commit 2023-05-25)