# 替换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
# 替换homebrew-cask.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-cask.git
# 应用生效
brew update
替换homebrew-bottles:
如果你当前使用的默认shell是bash,则执行
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
如果使用的是 zsh,执行
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
恢复默认设置
# 重置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
# 重置homebrew-cask.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask"
$ git remote set-url origin https://github.com/Homebrew/homebrew-cask.git
删除 ~/.bash_profile 或 ~/.zshrc 中的 HOMEBREW_BOTTLE_DOMAIN 环境变量,重新 source一下
参考:https://developer.aliyun.com/mirror/homebrew/?spm=a2c6h.25603864.0.0.462a2c03cEc2Jk