Homebrew切换成国内源

将 Homebrew 切换成国内的源可以显著提高软件包的下载速度。以下是详细步骤,帮助你将 Homebrew 的主仓库和核心仓库切换到国内镜像源。这里以中国科学技术大学(USTC)的镜像源为例,其他镜像源的切换方法类似。

切换 Homebrew 主仓库

  1. 打开终端

  2. 切换 Homebrew 主仓库到 USTC 镜像

    cd "$(brew --repo)" && git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
    
  3. 验证是否切换成功

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

切换 Homebrew 核心仓库

  1. 切换 Homebrew 核心仓库到 USTC 镜像

    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
    
  2. 验证是否切换成功

    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote -v
    

切换 Homebrew Cask 仓库

  1. 切换 Homebrew Cask 仓库到 USTC 镜像

    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" && git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
    
  2. 验证是否切换成功

    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" && git remote -v
    

其他常用的国内镜像源

除了中国科学技术大学(USTC)提供的镜像外,还有其他一些常用的国内镜像源:

  • 清华大学

    • Homebrew 主仓库:https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
    • Homebrew 核心仓库:https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
    • Homebrew Cask 仓库:https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
  • 北京大学

    • Homebrew 主仓库:https://mirrors.pku.edu.cn/homebrew/brew.git
    • Homebrew 核心仓库:https://mirrors.pku.edu.cn/homebrew/homebrew-core.git
    • Homebrew Cask 仓库:https://mirrors.pku.edu.cn/homebrew/homebrew-cask.git
  • 阿里云

    • Homebrew 主仓库:https://mirrors.aliyun.com/homebrew/brew.git
    • Homebrew 核心仓库:https://mirrors.aliyun.com/homebrew/homebrew-core.git
    • Homebrew Cask 仓库:https://mirrors.aliyun.com/homebrew/homebrew-cask.git

恢复默认源

如果你需要恢复到 Homebrew 的默认源,可以使用以下命令:

  1. 恢复 Homebrew 主仓库

    cd "$(brew --repo)" && git remote set-url origin https://github.com/Homebrew/brew
    
  2. 恢复 Homebrew 核心仓库

    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://github.com/Homebrew/homebrew-core
    
  3. 恢复 Homebrew Cask 仓库

    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" && git remote set-url origin https://github.com/Homebrew/homebrew-cask
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值