替换 Mac HomeBrew 安装源

本文记录替换 Mac HomeBrew 安装源的方法.

更换为国内源

# 替换 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.ustc.edu.cn/homebrew-cask.git

# 替换 homebrew-bottles :
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile

# 更新配置
source ~/.bash_profile

# 验证
brew update

重置为官方源

# 重置 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
#Caskroom 的 Git 地址在 2018年5月25 日从 https://github.com/caskroom/homebrew-cask 迁移到了 https://github.com/Homebrew/homebrew-cask

# 最后注释掉 /.bash_profile 里的 homebrew-bottles 并保存, 以 bash 为例
cd ~
open .bash_profile

# 更新 .bash_profile
source .bash_profile
文章作者: David Liu
文章链接: https://davidliu.now.sh/2020/10/23/replace_mac_home_brew_source/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 David Liu's Blog