Mac本安装homebrew后git报错解决1

安装完成homebrew后,运行brew -v

提示

Homebrew 4.0.6-186-g98a2923

fatal: detected dubious ownership in repository at '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'

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: detected dubious ownership in repository at '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'

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)

实际就是homebrew的根目录没有信任Homebrew/homebrew-core (no Git repository)和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 -v,即可看到这两个版本提示

brew -v

Homebrew 4.0.6-186-g98a2923

Homebrew/homebrew-core (git revision 5eaa252887b; last commit 2023-03-20)

Homebrew/homebrew-cask (git revision 51351c7c47; last commit 2023-03-20)

猜你喜欢

转载自blog.csdn.net/Little_Bully/article/details/129668280