brew 替换源与还原

查看本地使用的镜像源

cd "$(brew --repo)" && git remote -v

若如下结果表示使用的是官方源

origin	https://github.com/Homebrew/brew (fetch)
origin	https://github.com/Homebrew/brew (push)

切换镜像源有三个库要切换

3 个仓库地址:

  • brew.git
  • homebrew-core.git
  • homebrew-bottles

切换 Homebrew 镜像源为阿里镜像源

  1. 更换brew.git
cd "$(brew --repo)" && git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
  1. 更换 homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
  1. 更换homebrew-cask.git(M1的配置和之前的不一样,没有 cask 这个目录,忽略)
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" && git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-cask.git
  1. 更换homebrew-bottles,在对应shell配置执行
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc &&
source ~/.zshrc
  • 本人使用的zshrc,若是使用bash,操作文件变更成bash_profile
  1. **brew update ** 刷新配置
brew update

切换 Homebrew 镜像源为官方

  1. 更换brew.git
cd "$(brew --repo)" && git remote set-url origin https://github.com/Homebrew/brew.git
  1. 更换 homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://github.com/Homebrew/brew.git
  1. 更换homebrew-cask.git(M1的配置和之前的不一样,没有 cask 这个目录,忽略)
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" && git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-cask.git
  1. 更换homebrew-bottles,在对应shell中注释掉刚刚的配置
vim ~/.zshrc
# export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles
source ~/.zshrc
  • 本人使用的额ezshrc,若是使用bash,操作文件变更成bash_profile
  1. **brew update ** 刷新配置
brew update
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值