1、安装
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
2、切换为清华源
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
3、替换homebrew-cask默认源
# 修改为中科大的 cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-cask.git
4、替换 Homebrew-bottles默认源
# 临时替换 export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles # 永久替换 # bash echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile # zsh echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc source ~/.zshrc
其他国内源
# 中国科大: https://mirrors.ustc.edu.cn/brew.git https://mirrors.ustc.edu.cn/homebrew-core.git https://mirrors.ustc.edu.cn/homebrew-bottles # 清华大学: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles # ali https://mirrors.aliyun.com/homebrew/brew.git https://mirrors.aliyun.com/homebrew/homebrew-core.git https://mirrors.aliyun.com/homebrew/homebrew-bottles重置回官方源[/info
# 重置 brew.git 为官方源 $ git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git # 重置 homebrew-core.git 为官方源 $ git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git # 重置 homebrew-cask.git 为官方源 $ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask # zsh 注释掉 HOMEBREW_BOTTLE_DOMAIN 配置 $ vi ~/.zshrc # export HOMEBREW_BOTTLE_DOMAIN=xxxxxxxxx # bash 注释掉 HOMEBREW_BOTTLE_DOMAIN 配置 $ vi ~/.bash_profile # export HOMEBREW_BOTTLE_DOMAIN=xxxxxxxxx # 刷新源 $ brew update
查看当前Homebrew源
# 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
文章评论