替换及重置 Homebrew 默认源

替换默认源

1
2
3
4
5
6
7
# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

替换Homebrew Bottles源请向下看。

在中科大源失效或宕机时可以: 1. 使用清华源。 2. 切换回官方源。

1
2
3
4
5
6
7
# 重置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

注释掉bash配置文件里的有关Homebrew Bottles即可恢复官方源。 重启bash或让bash重读配置文件。

Homebrew Bottles源

Homebrew Bottles是Homebrew提供的二进制代码包,目前镜像站收录了以下仓库:

  • homebrew/homebrew-core
  • homebrew/homebrew-dupes
  • homebrew/homebrew-games
  • homebrew/homebrew-gui
  • homebrew/homebrew-python
  • homebrew/homebrew-php
  • homebrew/homebrew-science
  • homebrew/homebrew-versions
  • homebrew/homebrew-x11

对于 bash 用户:

1
2
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

对于 zsh 用户:

1
2
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

码云镜像

1
2
3
cd "$(brew --repo)" && git remote set-url origin https://git.coding.net/homebrew/homebrew.git

$ cd $home && brew update