brew update 报错 "fatal: Could not resolve HEAD to a revision"

brew update 报错 "fatal: Could not resolve HEAD to a revision"

执行brew update命令时:

% brew update
error: Not a valid ref: refs/remotes/origin/master
fatal: Could not resolve HEAD to a revision
Already up-to-date.

解决
% brew update --verbose

% 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...
Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-cask...
fatal: unable to access 'https://github.com/Homebrew/homebrew-cask/': Failed to connect to github.com port 443: Operation timed out
Error: Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-cask failed!
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

打开报错路径:

% cd /opt/homebrew/Library/Taps/homebrew/homebrew-core
% ls -al

total 0
drwxr-xr-x   3 tyrone.lin@ui.com  admin   96  4 13 16:34 .
drwxr-xr-x   4 tyrone.lin@ui.com  admin  128  4 14 11:31 ..
drwxr-xr-x  12 tyrone.lin@ui.com  admin  384  4 14 11:44 .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.

之后便可正常执行其他命令了

eg. % brew install rbenv ruby-build

转载自: https://www.jianshu.com/p/b2de788c3c6d

posted @ 2022-03-15 10:35  Bitten  阅读(322)  评论(0编辑  收藏  举报