一、获取 install 文件
把官网给的脚本拿下来
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install
二、更改脚本中的资源链接
打开文件brew_install
open brew_install
替换成清华大学的镜像,修改如下两句:
BREW_REPO = “https://github.com/Homebrew/brew“.freeze
CORE_TAP_REPO = “https://github.com/Homebrew/homebrew-core“.freeze
更改为这两句
BREW_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git".freeze
CORE_TAP_REPO = "https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git".freeze
也可以换成别家的(注意:新版brew没有CORE_TAP_REPO,不用考虑更换)
** 三、运行脚本**
/usr/bin/ruby brew_install
** 四、出现如下代码时,不用等了,直接关掉命令窗口**
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
五、进入下面的 Taps 目录,clone homebrew-core
cd /usr/local/Homebrew/Library/Taps/homebrew
六、依次输入以下命令:
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
brew update
出现Already up-to-date.表示成功
八、复原
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
brew update
出现Already up-to-date.表示成功
然后... 然后... 你就可以快乐的玩brew了