Tag Archives: fatal: Could not resolve HEAD to a revision

[Solved] brew update Error: “fatal: Could not resolve HEAD to a revision”

brew update reports “fatal: Could not resolve HEAD to a revision”

When executing the brew update command:

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

resolve
% 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

Open the error path:

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

total 0
drwxr-xr-x   3 [email protected]  admin   96  4 13 16:34 .
drwxr-xr-x   4 [email protected]  admin  128  4 14 11:31 ..
drwxr-xr-x  12 [email protected]  admin  384  4 14 11:44 .git

implement:

% git fetch --prune origin
% git pull --rebase origin master

From https://mirrors.ustc.edu.cn/homebrew-core
 * branch                  master     -> FETCH_HEAD

Execute after success

% brew update

Already up-to-date.

Then you can execute other commands normally

eg. % brew install rbenv ruby-build