brew 切换源

切换到国内源

# 替换brew.git:
$ cd "$(brew --repo)"
# 中国科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 清华大学:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

# 替换homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
# 中国科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 清华大学:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

# 替换homebrew-bottles:
# 中国科大:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
# 清华大学:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 应用生效:
$ brew update

切换到官方源

# 重置brew.git:
$ cd "$(brew --repo)"
$ git remote set-url origin https://github.com/Homebrew/brew.git

# 重置homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://github.com/Homebrew/homebrew-core.git

报错

$ brew update
fatal: Could not resolve HEAD to a revision
Already up-to-date.
$ brew update --verbose
Checking if we need to fetch /opt/homebrew...
Checking if we need to fetch /opt/homebrew/Library/Taps/homebrew/homebrew-cask...
Fetching /opt/homebrew...
Checking if we need to fetch /opt/homebrew/Library/Taps/homebrew/homebrew-core...
Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-core...
Updating /opt/homebrew...
Branch 'master' set up to track remote branch 'master' from 'origin'.
Switched to and reset branch 'master'
Your branch is up to date with 'origin/master'.
Switched to and reset branch 'stable'
Current branch stable is up to date.

# 进入这个地址
Updating /opt/homebrew/Library/Taps/homebrew/homebrew-core...
fatal: Could not resolve HEAD to a revision
Already up-to-date.

$ cd /opt/homebrew/Library/Taps/homebrew/homebrew-core            
homebrew-core (master) » ll                                           
total 0
drwxr-xr-x   3 machao  admin   96 12  2 12:14 .
drwxr-xr-x   4 machao  admin  128 12  2 12:49 ..
drwxr-xr-x  12 machao  admin  384 12  2 14:20 .git

# 从新操作
$ git fetch --prune origin                     
$ git pull --rebase origin master              
From https://mirrors.ustc.edu.cn/homebrew-core
 * branch                    master     -> FETCH_HEAD
$ brew update
Already up-to-date.
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1.问题描述   在Mac上安装brew时,如果使用官方推荐的方式,会耗费很长时间,并且也不一定能成功 2. 解决...
    shandingdongren阅读 54,633评论 8 19
  • 1、通过CocoaPods安装项目名称项目信息 AFNetworking网络请求组件 FMDB本地数据库组件 SD...
    阳明AI阅读 16,056评论 3 119
  • 一闪一暗 明灭没有节奏 与时间同行 在夜的包裹中 它沉默 像死去的风声 安静的 存在并呼吸着 游动的火光卷带着它过...
    光皂阅读 1,661评论 0 1
  • 正月十四,天然居,岳阳楼。 时光流转,二十四年宛如昨天,突然又成了怯怯地说不出话来的那个孩子,在恩...
    NFEX吴穷阅读 3,060评论 1 3
  • 我不知道什么是最好的结局,婚姻不是,离别更加不对。爱情在最开始就达到了最好,怎么走都是下坡路。切实的拥有、陪伴和相...
    入世的鹭鸶阅读 1,801评论 0 0

友情链接更多精彩内容