查看默认源地址
首先我们查看默认的源地址:
$ cd "$(brew --repo)"
/usr/local/Homebrew(stable) $ git remote -v
输出如下内容:
origin https://github.com/Homebrew/brew (fetch)
origin https://github.com/Homebrew/brew (push)
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core(master) $ git remote -v
输出如下内容:
origin https://github.com/Homebrew/homebrew-core (fetch)
origin https://github.com/Homebrew/homebrew-core (push)
修改源地址
方式一:替换为清华的brew源
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
$ brew update
方式二:替换为中科大的brew源
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
$ brew update
还原默认源地址
如果想换回默认源,可以执行如下命令重置回官方默认源:
$ cd "$(brew --repo)"
$ git remote set-url origin https://github.com/Homebrew/brew.git
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://github.com/Homebrew/homebrew-core.git
$ brew update
参考资料
https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/
http://mirrors.ustc.edu.cn/help/brew.git.html