mac报错Error: homebrew-core is a shallow clone.解决

报错信息: ~/Documents/» brew install treeError: homebrew-core is a shallow clone.

报错信息

~/Documents/» brew install tree
Error: homebrew-core is a shallow clone.
To `brew update`, first run:git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

解决方案

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

可能会因为网络原因报错,换几个时间点,多执行几次,执行期间显示如下:
在这里插入图片描述

其实就是把https://github.com/Homebrew/homebrew-core/部分下载下来重新更新本地仓库。

然后可以brew update验证一下是不是不会报错了


如果还有报错: homebrew-cask is a shallow clone.
类似的,可以使用

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow

相对靠谱的内容:

  • stack overflow:How to remove the shallow clone warning from HomeBrew
  • HomeBrew - Error: homebrew-core is a shallow clone.

有风险,不建议采用

  • [Solved] Mac Homebrew Error: homebrew-core is a shallow clone.
  • 这一解决方案的实践:Mac homebrew报错Error: homebrew-core is a shallow clone.