brew速度太慢更换国内源

更新到最新版本后好像方法变了,只需要修改环境变量即可

####### brew安装镜像加速
#
# brew安装仓库加速配置 这里可选配置阿里,ustc或者清华的加速地址, 他们的加速地址前缀如下:
# 阿里: https://mirrors.aliyun.com/homebrew   这个加速地址,结果测试无法git clone 访问,在克隆taps时可能会出现问题
# tuna: https://mirrors.tuna.tsinghua.edu.cn
# ustc: https://mirrors.ustc.edu.cn
# 加速地址的后面部分都是一样的,修改前缀即可
#
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"
export HOMEBREW_NO_ENV_HINTS="1"

以下为旧方法

brew下载更新的时候访问速度太慢了,原因是brew的默认源是github的,github的速度大家众所皆知,为了解决这个问题,我们可以吧brew换成国内的源,这里我们更换成中科大的源。

命令如下:

进入brew的目录

cd "$(brew --repo)"

查看当前brew设置的源

git remote -v

我这里是默认的显示是github

liqingcan-pc:Homebrew liqingcan$ git remote -v
origin    https://github.com/Homebrew/brew (fetch)
origin    https://github.com/Homebrew/brew (push)

接下来执行这个命令把源换成中科大的

git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

再次查看当前源,已经变成中科大的了

liqingcan-pc:Homebrew liqingcan$ git remote -v
origin    https://mirrors.ustc.edu.cn/brew.git (fetch)
origin    https://mirrors.ustc.edu.cn/brew.git (push)

使用brew update使源生效即可

想要重置回默认的,只要把源地址再修改成github的就可以了

git remote set-url origin https://github.com/Homebrew/brew.git

觉得内容还不错?打赏个钢镚鼓励鼓励!!👍