1.输入命令brew cleanup && brew update,更新Homebrew,出现Error: Fetching /usr/local/Homebrew failed! fatal: Could not resolve HEAD to a revision这个原因是因为源不通,代码来不下来

 chenxx@MEIZU-16s-Pro  /usr/local/Homebrew   stable 3.3.7  brew cleanup && brew update                               ✔  365  12:43:06
Error: Fetching /usr/local/Homebrew failed!
fatal: Could not resolve HEAD to a revision

2.查看问题:

 chenxxx@MEIZU-16s-Pro  /usr/local/Homebrew/Library/Taps/homebrew   stable 3.3.7  ls -all                             ✔  370  12:48:58
total 0
drwxr-xr-x   4 chenlintao  admin  128 12  6 17:25 .
drwxr-xr-x   3 chenlintao  admin   96 12  6 16:32 ..
drwxr-xr-x  17 chenlintao  admin  544 12  6 17:26 homebrew-cask
drwxr-xr-x   3 chenlintao  admin   96 12  6 16:32 homebrew-core
 chenxxx@MEIZU-16s-Pro  /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core   master  ls -all                     ✔  368  12:48:41
total 0
drwxr-xr-x   3 chenlintao  admin   96 12  6 16:32 .
drwxr-xr-x   4 chenlintao  admin  128 12  6 17:25 ..
drwxr-xr-x  11 chenlintao  admin  352 12  7 12:43 .git

homebrew-core文件夹有问题。

3.针对上述问题,解决方法就是更换国内镜像源,及更改为中科大的国内镜像,同时把homebrew-core的镜像地址也设为中科大的国内镜像。

依次执行:

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

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即可成功更新。

 chenxxx@MEIZU-16s-Pro  /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core   master  brew update                 ✔  390  12:58:08
Updated 1 tap (homebrew/cask).
==> Updated Casks
metasploit

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐