在mac系统中,使用homebrew可以很方便的管理包。按照官网的说明执行以下命令时总是报错: 
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

应该是这个资源访问有问题,那么我们可以尝试使用国内的镜像。给大家推荐一个中国科学技术大学的镜像站点,里面有各种资源: 
https://mirrors.ustc.edu.cn/brew.git

言归正传,开始踩坑

第一步,获取install文件
把官网给的脚本拿下来 
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install >> brew_install

第二步,更改脚本中的资源链接,替换成中国科学技术大学的镜像
就是把这两句 
BREW_REPO = “https://github.com/Homebrew/brew“.freeze 
CORE_TAP_REPO = “https://github.com/Homebrew/homebrew-core“.freeze 
更改为这两句 
BREW_REPO = “https://mirrors.ustc.edu.cn/brew.git “.freeze 
CORE_TAP_REPO = “https://mirrors.ustc.edu.cn/homebrew-core.git“.freeze 
当然如果这个镜像有问题的话,可以换成别的

第三步,执行脚本
/usr/bin/ruby brew_install

然后可以看到这几句:

==> Tapping homebrew/core

Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...

fatal: unable to access 'https://github.com/Homebrew/homebrew-core/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

Error: Failure while executing: git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

Error: Failure while executing: /usr/local/bin/brew tap homebrew/core

liyuanbadeMacBook-Pro:~ liyuanba$ git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

出现这个原因是因为源不通,代码来不下来,解决方法就是更换国内镜像源:

执行下面这句命令,更换为中国科学技术大学的镜像:

git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

就下载成功了

然后把homebrew-core的镜像地址也设为中国科学技术大学的国内镜像

cd "$(brew --repo)"

git remote set-url origin https://mirrors.ustc.edu.cn/brew.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

执行更新,成功:

brew update

最后用这个命令检查无错误:

brew doctor

这样海外和已经有系统全局代理设置的朋友们就可以直接使用 brew 命令安装软件了。

接着换源:
直接使用 Homebrew 还需要更改默认源,不然谁用谁想打人,原因你懂的。以下是将默认源替换为国内 USTC 源的方法。

替换核心软件仓库

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
替换 cask 软件仓库(提供 macOS 应用和大型二进制文件)

cd "$(brew --repo)"/Library/Taps/caskroom/homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
替换 Bottles 源(Homebrew 预编译二进制软件包)

bash(默认 shell)用户:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
zsh 用户:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

基本用法:
假定操作对象为 wget,请替换为自己需要的软件包名

操作 命令
更新 Homebrew brew update
更新所有安装过的软件包 brew upgrade
更新指定的软件包 brew upgrade wget
查找软件包 brew search wget
安装软件包 brew install wget
卸载软件包 brew remove wget
列出已安装的软件包 brew list
查看软件包信息 brew info wget
列出软件包的依赖关系 brew deps wget
列出可以更新的软件包 brew outdated
参考:

Homebrew 中文主页

https://brew.sh/index_zh-cn.html

Homebrew Bottles 源使用帮助

http://mirrors.ustc.edu.cn/help/homebrew-bottles.html

Homebrew Cask 源使用帮助

http://mirrors.ustc.edu.cn/help/homebrew-cask.git.html

Homebrew Core 源使用帮助

http://mirrors.ustc.edu.cn/help/homebrew-core.git.html
---------------------
作者:QC班长
来源:CSDN
原文:https://blog.csdn.net/qq_35624642/article/details/79682979
版权声明:本文为博主原创文章,转载请附上博文链接!

转载于:https://www.cnblogs.com/jerryspace/p/10313955.html

homebrew安装问题(Failed during: git fetch origin master:refs/remotes/origin/master --tags --force)...相关推荐

  1. windows git fetch 时报错error: cannot lock ref ‘refs/remotes/origin/feature-1‘: there is a non-empty di

    解决方式   看报错知道是存在feature-1这样的分支,导致在fetch或者pull的时候,发现该分支不为空而失败:同理其他cannot lock ref提示的错误也是相关分支异常导致.   处理 ...

  2. git pull时提示错误:warning: ignoring broken ref refs/remotes/origin/HEAD的解决办法

    git pull时提示错误:warning: ignoring broken ref refs/remotes/origin/HEAD的解决办法 我用的是IDEA开发的GIT项目,首先找到你项目的根目 ...

  3. 2021-07-12Git - git pull时遇到error: cannot lock ref ‘refs/remotes/origin/master‘: unable to resolve...

    git pull时遇到问题及解决方法 问题描述: 解决方法及原因分析: 1.git log 错误: 解决方法:修复 .git/refs/heads/分支名 原因分析:IDE的错误关闭 2.git pu ...

  4. git push 遇到 error: cannot update the ref ‘refs/remotes/origin/master‘: Permission denied

    在昨天晚上就git push之后毫无反应,连报错都无,一顿操作毫无变化于是就放弃了去睡觉. 今天起床之后再次尝试,怎么说呢,还算是变好了,至少有报错了= = 根据各种博客尝试了一遍. rm -rf . ...

  5. error: cannot lock ref 'refs/remotes/origin/master': unable to resolve reference 'refs/remotes/origi

    当本地修改代码,然后远程也修改了代码时,想要拉取远程最新代码覆盖本地代码 1).查看本地修改 git status 2).隐藏本地修改 git stash 3).拉取远程最新代码git pull,失败 ...

  6. error: cannot lock ref ‘refs/remotes/origin/release/xxxx‘: ‘refs/remotes/origin/release‘ 已存在,无法创建

    在一次远程拉取release 分支的时候提示error: cannot lock ref 'refs/remotes/origin/release/xxxx': 'refs/remotes/origi ...

  7. error: cannot lock ref ‘refs/remotes/origin/master‘

    error: cannot lock ref 'refs/remotes/origin/master' 报错信息 remote: Azure Repos remote: Found 41 object ...

  8. error: cannot lock ref 'refs/remotes/origin/test/pressure-test': 'refs/remotes/origin/test' exists;

    用git pull 拉取远程分支 报错 ➜  api git:(master) git pl        error: cannot lock ref 'refs/remotes/origin/te ...

  9. error: cannot lock ref ‘refs/remotes/origin/douyin/open‘: ‘refs/remotes/origin/douyin‘ exists;

    解决方案: git branch -D douyin git gc --prune=now git remote prune origin git pull

最新文章

  1. 今天是2013年06月21日,博客之路开始了!
  2. 华为p20可以用云闪付吗_华为hcIE有多难?零基础可以通过华为hcie认证吗?
  3. JVM-08垃圾收集Garbage Collection【GC常用参数】
  4. 【数据结构与算法】之“接雨水”的算法求解
  5. Asp.Net验证控件和表达式测试题
  6. Install Python 3.6 on Ubuntu 16.04, from source
  7. 程序人生:初学者最常问的几个问题
  8. Ubuntu远程服务器创建新用户并赋予权限
  9. 【leetcode】 Unique Binary Search Trees (middle)☆
  10. vue 电子签名插件
  11. 一、C语言[typedef、结构体、共用体、枚举体]
  12. python——识别真实键盘按下模拟键盘按下
  13. 学计算机的高数学什么,儿子大一,学的计算机科学与技术,感觉高数特别难,都学不会怎么办呢?有什么好办法?...
  14. 旋转矩阵、欧拉角、旋转矢量及四元数的介绍和工程应用
  15. GITHUB执行git clone项目下载不全不完整
  16. 游戏本电脑性价比排行2020榜单,这款新发布的成黑马!
  17. 江南春:30年,我用1000亿,换来这99句话
  18. UsbAccessory和UsbDevice的区别
  19. ROS学习| navigation基本导航
  20. Go实现 Bit 数组(集合)

热门文章

  1. 帝国cms 实现百度主动推送 (非插件)
  2. 【行研报告】2021中国品牌数字化实战研究报告—附下载链接
  3. 新入职了一个00后卷王,天天加班12点,太让人崩溃......
  4. 任务三——决策树算法梳理
  5. goconvey的使用
  6. Python指定位置插入元素
  7. 王世安计算机仿真工作室,运用实时全局光照打造灯光模拟仿真软件
  8. C语言知识的回顾(笔记)
  9. 4.Vue项目中下载本地pd、word、excel文件
  10. oracle r12 客户表,Oracle ERP R12表结构