Homebrew设置新源

  1. 首先取消代理
$ git config --global --unset http.proxy 
$ git config --global --unset https.proxy
  1. 查看当前镜像
# brew.git镜像源
git -C "$(brew --repo)" remote -v

# homebrew-core.git镜像源
git -C "$(brew --repo homebrew/core)" remote -v

# homebrew-cask.git镜像源
git -C "$(brew --repo homebrew/cask)" remote -v

3.更换镜像

# 替换成阿里巴巴的 brew.git 仓库地址:
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
 
# 替换成阿里巴巴的 homebrew-core.git 仓库地址:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git


# 替换成阿里巴巴的 homebrew-bottles 访问 URL:

# 若使用bash
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 若使用zsh
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' 
$ source ~/.zshrc
  1. 更换后立即更新源
$ brew update

#需要等较长时间,如果报fail,请尝试下列命令
$ brew doctor
$ brew update-reset
$ brew update

5.科大源
使用以下内容替换步骤3中的内容

# 对应仓库地址
https://mirrors.ustc.edu.cn/brew.git
https://mirrors.ustc.edu.cn/homebrew-core.git
https://mirrors.ustc.edu.cn/homebrew-cask.git

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

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

$ brew update

6.恢复源
使用以下内容替换步骤3中的内容

# 对应仓库地址
https://github.com/Homebrew/brew.git
https://github.com/Homebrew/homebrew-core.git
https://github.com/Homebrew/homebrew-cask.git

# 找到 ~/.bash_profile 或者 ~/.zshrc 中的HOMEBREW_BOTTLE_DOMAIN 一行删除

$ brew update
posted @ 2020-07-09 20:42  Tzbubble  阅读(192)  评论(0编辑  收藏  举报