有问题,可在评论区询问。
-
准备工作,务必保证github可用,如果访问很慢,考虑绕过远程dns解析,方法是修改本地hosts,具体方法可自行搜索
修改如:
151.101.44.249 github.global.ssl.fastly.net 192.30.253.113 github.com 103.245.222.133 assets-cdn.github.com 23.235.47.133 assets-cdn.github.com 203.208.39.104 assets-cdn.github.com 204.232.175.78 documentcloud.github.com 204.232.175.94 gist.github.com 107.21.116.220 help.github.com 207.97.227.252 nodeload.github.com 199.27.76.130 raw.github.com 107.22.3.110 status.github.com 204.232.175.78 training.github.com 207.97.227.243 www.github.com 185.31.16.184 github.global.ssl.fastly.net 185.31.18.133 avatars0.githubusercontent.com 185.31.19.133 avatars1.githubusercontent.com 192.30.253.120 codeload.github.com 199.232.28.133 raw.githubusercontent.com
-
开始
git clone https://github.com/Homebrew/install.git
-
cd install
忽略里面的install文件,聚焦install.sh
-
vim install.sh
替换 BREW_REPO="https://github.com/Homebrew/brew"
为 BREW_REPO="https://mirrors.ustc.edu.cn/brew.git"
或其他国内镜像然后执行
-
./install.sh
之后就是等待一会,直到完成
-
然后开始替换brew为国内镜像源
cd "$(brew --repo)" git remote set-url origin https://mirrors.ustc.edu.cn/brew.git cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
//如果你发现Taps/homebrew/homebrew-core这样的路径不存在 就直接新建
//或者执行下brew install xx 发现太慢就终止掉,这时你也会发现以上路径已经创建,然后继续
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
并查看homebrew-core是否是空目录,如果是,执行
```shell
git pull
-
然后执行
brew update
大功告成。
注意:重要的后续参考