brew 是一个很好地Mac下管理应用包的工具,可是第一次安装后直接使用时,下载和更新很慢,这是因为brew的镜像源在国外,我们的网络访问会很慢,不过我们可以修改镜像源为国内,网上有很多博客提供的方法,我试了很多,大部分都过时了,以下是我经过测试截止2019年最新的官方方法
更换为国内镜像源(清华大学)
cd /usr/local/Homebrew
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
brew update
在使用过最后brew update后,需要等待一部分时间,大概一分钟,如果看见终端上方一直在变化就离成功不远了,最后会在终端中显示更新信息,就算是大功告成了。
复原的方法
cd /usr/local/Homebrew
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git
brew update