問題:
Mac 下執(zhí)行 brew update 時(shí)妄均,報(bào)如下錯(cuò)誤:
Error:
homebrew-core is a shallow clone.
homebrew-cask 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-cask fetch --unshallow
These commands may take a few minutes to run due to the large size of the repositories.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
如果只需按上述提示執(zhí)行相應(yīng)命令即可:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
但是 git 倉庫是國外的茂契,速度慢撤摸,還經(jīng)常被墻徽千,導(dǎo)致 early EOF 之類的錯(cuò)誤。
更換數(shù)據(jù)源:
## 更新 homebrew-cask
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
## 更換源
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
## 更新珍手,由于已經(jīng) cd 到相應(yīng)文件夾了办铡,因此不需要通過 -C 指定路徑了
git fetch --unshallow
## 更新 homebrew-core
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-core
## 更換源
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
## 更新
git fetch --unshallow
如果還不能更新辞做,執(zhí)行如下命令查看遠(yuǎn)端 repo 是不是設(shè)置錯(cuò)了。
git remote -v
最后執(zhí)行 brew update
即可寡具。