更换Homebrew 源

以下是查看和修改 Homebrew 源的详细步骤,适用于需要切换到国内镜像以加速下载的场景:

1. 查看当前 Homebrew 源

bash 复制代码
# 查看 brew 主仓库地址
git -C "$(brew --repo)" remote get-url origin

# 查看 homebrew-core 仓库地址
git -C "$(brew --repo homebrew/core)" remote get-url origin

# 查看 homebrew-cask 仓库地址(如安装了 cask)
git -C "$(brew --repo homebrew/cask)" remote get-url origin

2. 修改为国内镜像源(以中科大镜像为例)

bash 复制代码
# 设置 brew 主仓库
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git

# 设置 homebrew-core 仓库
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

# 设置 homebrew-cask 仓库(可选)
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

# 刷新缓存
brew update

3. 其他国内镜像源选项

  • 清华大学镜像:

    bash 复制代码
    # brew 主仓库
    git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
    
    # homebrew-core
    git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
    
    # homebrew-cask
    git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
  • 阿里云镜像:

    bash 复制代码
    # brew 主仓库
    git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
    
    # homebrew-core
    git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

4. 恢复为官方源

bash 复制代码
# brew 主仓库
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git

# homebrew-core
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git

# homebrew-cask
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git

5. 验证修改是否成功

再次运行步骤 1 的命令,确认输出的仓库地址已变更为所选镜像源。

注意事项

  1. 中科大镜像限制:中科大镜像仅支持 macOS 和 Linux 系统,不支持 Windows。

  2. 环境变量影响 :如果设置了 HOMEBREW_BREW_GIT_REMOTE 或 HOMEBREW_CORE_GIT_REMOTE 环境变量,可能会覆盖手动设置的源。检查并删除这些环境变量:

    bash 复制代码
    unset HOMEBREW_BREW_GIT_REMOTE
    unset HOMEBREW_CORE_GIT_REMOTE
  3. 更新问题 :切换镜像后若遇到更新失败,可尝试清除缓存并重新更新:

    bash 复制代码
    brew cleanup
    brew update --force

根据网络情况选择合适的镜像源,国内推荐使用中科大或清华的镜像。

相关推荐
QiLinkOS11 小时前
行业规则的“强制升级”:从“数量竞赛”到“质量博弈”
大数据·人工智能·产业链坐标定位·矩规双螺旋归因模型·矩规评级·科创技术评级·技术坐标刻度模型
风翼靓崽12 小时前
ES综合日志平台搭建
大数据·elasticsearch·搜索引擎
TDengine (老段)13 小时前
TDengine IDMP ---- Excel 插件
大数据·数据库·excel·时序数据库·tdengine·涛思数据
大大大大晴天1 天前
Agent 的“手和脚”:工具接口如何做到安全、可靠与可治理
大数据
XW9632581 天前
除湿机行业组织能力与人才地图报告
大数据·服务器·网络·数据结构·数据库·人工智能
大大大大晴天1 天前
每天认识一个组件:ZooKeeper
大数据
Java展博1 天前
[工程化基本功] 合并两条分支时,merge 和 rebase 到底改了谁的历史
大数据·elasticsearch·搜索引擎
Lansonli2 天前
大数据Spark(九十五):Spark Shuffle 参数调优全解析
大数据·分布式·spark
老周聊架构2 天前
从智能应用到智能组织:一场架构级的范式跃迁
大数据·人工智能·架构
Nefu_lyh2 天前
【Spark】05Spark 数据读取与保存:文件格式、文件系统与结构化数据
大数据·分布式·spark