在macOS上使用Homebrew的,对官方源的速度都深有体会,慢的能让你感动的痛哭流涕,哪怕是一个极其微小的软件都要半个多小时。
更新 git repo 源
# 替换brew.git
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 替换homebrew-core.git
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# 应用刷新
$ brew update
更新 bottles 源
# 使用zsh
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc
# 使用bash
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
我用的是阿里云的源,速度还比较不错(也可以自行搜索其他的源:清华、腾讯、七牛...)
恢复出厂设置
某些时候,可能需要恢复默认的配置
# 替换brew.git
$ cd "$(brew --repo)"
$ git remote set-url origin https://github.com/Homebrew/brew.git
# 替换homebrew-core.git
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://github.com/Homebrew/homebrew-core.git
# 应用刷新
$ brew update
从 ~/.zshrc 或 ~/.bash_profile 中删除 HOMEBREW_BOTTLE_DOMAIN 环境变量,然后应用刷新
# zsh
$ source ~/.zshrc
# bash
$ source ~/.bash_profile
相关链接:Homebrew