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

在Mac上安装Homebrew后,运行brew -v出现权限错误,提示需要添加safe.directory的信任设置。解决方法是按照提示执行两条git配置命令:`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,确认问题已解决。

安装完成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)

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值