This worked for me:

brew tap --repair
brew cleanup
brew update-reset

After that I was able to brew update without any issues.

Possible culprit: dart-lang/dart: changed default branch name from master to main!

Answer from Mihai-Cristian on Stack Overflow
🌐
GitHub
github.com › dart-lang › homebrew-dart › issues › 131
brew update throws " couldn't find remote ref refs/heads/master" · Issue #131 · dart-lang/homebrew-dart
January 27, 2023 - ➜ ~ brew update fatal: couldn't ... taps can not read their remote branches: dart-lang/dart This is happening because the remote branch was renamed or deleted....
Author   dart-lang
Discussions

brew update leads to missing ref
Recently running brew update started causing the following error: fatal: couldn't find remote ref refs/heads/master Error: Fetching /usr/local/Homebrew/Library/Taps/sqitchers/homebrew-sqitch fa... More on github.com
🌐 github.com
4
August 10, 2020
The least you can do - Meta Jon
Lately it’s been failing and I finally had a moment to dig in this morning. Here was the error: $ brew update -q fatal: couldn't find remote ref refs/heads/master Error: Fetching /usr/local/Homebrew/Library/Taps/heroku/homebrew-brew failed! Error: Some taps failed to update! More on meta.jlericson.com
🌐 meta.jlericson.com
0
November 29, 2023
"error: Not a valid ref: refs/remotes/origin/master" when installing brew
Open your terminal using rosetta 2 and try to install again. It wil Work More on reddit.com
🌐 r/iOSProgramming
2
3
April 7, 2021
Brew update fails
I think brew fails because of the branch rename Expected Behavior brew update to succeed Actual Behavior ❯ brew update fatal: couldn't find remote ref refs/heads/master Error: Fetching /usr/loc... More on github.com
🌐 github.com
13
January 31, 2021
🌐
piaohua's blog
piaohua.github.io › post › tool › 20231022-brew-update-fail
fatal: couldn't find remote ref refs/heads/master - piaohua's blog
October 22, 2023 - fatal: couldn’t find remote ref refs/heads/master brew 更新提示失败如下: 1 2 3 4 5 > brew update Warning: No available formula with the name "ca-certificates". ==> Searching for similarly named formulae and casks... Error: No formulae or casks found for ca-certificates. fatal: Couldn't find remote ref refs/heads/master 解决方法: 1 /usr/local/Homebrew/Library/Taps/homebrew git:(master) > git pull origin master 更新后
🌐
GitHub
github.com › sqitchers › homebrew-sqitch › issues › 48
brew update leads to missing ref · Issue #48 · sqitchers/homebrew-sqitch
August 10, 2020 - Sqitch recently renamed the master branch to main (8842257). Homebrew relies on local Git origin settings for each tap so it's still looking for the old branch on origin. ... Note that untapping does not uninstall or erase any Sqitch settings, just refreshes the Homebrew tap. I could only see this causing an issue if you've been doing local edits in /usr/local/Homebrew/Library/Taps/sqitchers/homebrew-sqitch, in which case you could manually edit .git/config to reflect the new origin:main branch.
Author   sqitchers
🌐
Meta Jon
meta.jlericson.com › t › the-least-you-can-do › 244
The least you can do - Meta Jon
November 29, 2023 - I have a cronjob that updates Homebrew every night. Lately it’s been failing and I finally had a moment to dig in this morning. Here was the error: $ brew update -q fatal: couldn't find remote ref refs/heads/master Error: Fetching /usr/local/Homebrew/Library/Taps/heroku/homebrew-brew failed!
🌐
GitHub
github.com › orgs › Homebrew › discussions › 3352
Unable to install on M1 MacBook Air 12.3.1 · Homebrew · Discussion #3352
June 10, 2022 - Password: ==> This script will install: /opt/homebrew/bin/brew /opt/homebrew/share/doc/homebrew /opt/homebrew/share/man/man1/brew.1 /opt/homebrew/share/zsh/site-functions/_brew /opt/homebrew/etc/bash_completion.d/brew /opt/homebrew · Press RETURN/ENTER to continue or any other key to abort: ==> /usr/bin/sudo /usr/sbin/chown -R user:admin /opt/homebrew ==> Downloading and installing Homebrew... HEAD is now at ad13524bc Merge pull request #13402 from samford/livecheck/update-default-match_data fatal: couldn't find remote ref refs/heads/master Error: Fetching /opt/homebrew/Library/Taps/osx-cross/homebrew-avr failed!
🌐
GitHub
github.com › Homebrew › discussions › discussions › 1776
master branch does not exist · Homebrew · Discussion #1776
Reload to refresh your session. ... There was an error while loading. Please reload this page. Something went wrong. There was an error while loading. Please reload this page. ... There was an error while loading. Please reload this page. ... Something went wrong. There was an error while loading. Please reload this page. ... ==> Cloning https://github.com/WebAssembly/binaryen.git Updating /home/hwu/.cache/Homebrew/emscripten--binaryen--git fatal: couldn't find remote ref refs/heads/master Error: Failed to download resource "emscripten--binaryen" Failure while executing; `git fetch origin` exited with 128.
🌐
w3tutorials
w3tutorials.net › blog › fatal-couldn-t-find-remote-ref-refs-heads-master
Fix 'fatal: couldn't find remote ref refs/heads/master' Homebrew Installation Error: Step-by-Step Troubleshooting — w3tutorials.net
Update Git with brew upgrade git (once Homebrew is working) or via Git’s site. The "fatal: couldn't find remote ref refs/heads/master" error in Homebrew is almost always caused by referencing the outdated master branch.
Find elsewhere
🌐
Reddit
reddit.com › r/iosprogramming › "error: not a valid ref: refs/remotes/origin/master" when installing brew
r/iOSProgramming on Reddit: "error: Not a valid ref: refs/remotes/origin/master" when installing brew
April 7, 2021 -

I need to install brew, as I need pod, to execute "pod install"

However, I am getting stuck for long time, during brew installation.

I have tried

  1. Good Internet connection

  2. Try VPN

  3. Use Google DNS

  4. Restart few times

  5. No anti-virus

But... it still doesn't work for me :-( I am getting similar error, and I have no more idea how to proceed

I also check the git. Seem legit

yccheok@Yans-MacBook-Pro ~ % git --version 
git version 2.24.3 (Apple Git-128) 

Have setup email for git

yccheok@Yans-MacBook-Pro ~ % git config --global user.email xxx@gmail.com 

Have read

  1. #666

  2. https://stackoverflow.com/questions/39836190/homebrew-install-failed-during-git-fetch-origin-masterrefs-remotes-origin-mas

  3. Homebrew/brew#10878

But still getting the below error no matter how many times I have tried

yccheok@Yans-MacBook-Pro ~ % git config --global user.email xxx@gmail.com
yccheok@Yans-MacBook-Pro ~ % /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password).
Password:
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /usr/sbin/chown -R yccheok:admin /usr/local/Homebrew
==> Downloading and installing Homebrew...
remote: Enumerating objects: 19, done.
remote: Counting objects: 100% (19/19), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 28 (delta 12), reused 12 (delta 12), pack-reused 9
Unpacking objects: 100% (28/28), done.
From https://github.com/Homebrew/brew
   1777a03aac..731e25e0cc  master     -> origin/master
HEAD is now at 731e25e0cc Merge pull request #11041 from xxyzz/man
error: Not a valid ref: refs/remotes/origin/master
fatal: ambiguous argument 'refs/remotes/origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: SHA1 COLLISION FOUND WITH e9405b4a427b316ef3e5f01422bcf58e74982ad0 !
fatal: index-pack failed
Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core failed!
fatal: invalid upstream 'origin/master'
Failed during: /usr/local/bin/brew update --force --quiet

Any idea what could went wrong? Thanks

🌐
GitHub
github.com › tektoncd › homebrew-tools › issues › 2
Brew update fails · Issue #2 · tektoncd/homebrew-tools
January 31, 2021 - I think brew fails because of the branch rename Expected Behavior brew update to succeed Actual Behavior ❯ brew update fatal: couldn't find remote ref refs/heads/master Error: Fetching /usr/local/Homebrew/Library/Taps/tektoncd/homebrew-t...
Author   tektoncd
🌐
Jianshu
jianshu.com › p › e8d1925dafdd
Brew Error: couldn't find remote ref refs/heads/master - 简书
June 1, 2022 - The following taps can not read their remote branches: osx-cross/avr This is happening because the remote branch was renamed or deleted. Reset taps to point to the correct remote branches by running `brew tap --repair`
🌐
GitHub
github.com › Homebrew › brew › issues › 15452
`brew update` fails and hangs without any output · Issue #15452 · Homebrew/brew
May 18, 2023 - + [[ 304 == \3\0\4 ]] + exit + local tmp_failure_file=/opt/homebrew/Library/Taps/homebrew/homebrew-core/.git/TMP_FETCH_FAILURES + rm -f /opt/homebrew/Library/Taps/homebrew/homebrew-core/.git/TMP_FETCH_FAILURES + [[ -n '' ]] + git fetch --tags --force origin refs/heads/master:refs/remotes/origin/master + UPSTREAM_SHA_HTTP_CODE=304 + [[ -f /opt/homebrew/.git/FETCH_HEAD ]] + touch /opt/homebrew/.git/FETCH_HEAD + [[ -z '' ]] + [[ 304 == \3\0\4 ]] + exit ^C++ /usr/bin/pkill -P 8264 + [[ -f /opt/homebrew/Library/Taps/homebrew/homebrew-core/.git/TMP_FETCH_FAILURES ]] + cat /opt/homebrew/Library/Taps/
Author   Homebrew
🌐
MacRumors
forums.macrumors.com › software › developers › apple programming
Implications of upgrading Python? | MacRumors Forums
January 16, 2023 - HEAD is now at 3e257890d Merge pull request #14367 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-rspec-2.17.0 fatal: Couldn't find remote ref refs/heads/master Error: Fetching /usr/local/Homebrew/Library/Taps/osx-cross/homebrew-avr failed! Updated 2 taps (homebrew/cask and homebrew/core). Failed during: /usr/local/bin/brew update --force --quiet $ Any idea why and what I can do about it?
🌐
Xmtp
xmtp.org › docs › build › notifications › server
Run a push notification server for an app built with XMTP – Build with XMTP
July 2, 2024 - If you encounter any errors during brew update, such as fatal: couldn't find remote ref refs/heads/master, Homebrew is having trouble updating its repositories.
🌐
BudgetLightForum.com
budgetlightforum.com › led flashlights – general info
Anduril 2 feature change suggestions - Page 2 - LED Flashlights – General Info - BudgetLightForum.com
April 26, 2023 - thanks for the handholding… I pasted this into terminal: /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)” terminal replied: ==> Checking for sudo access (which may request your password)… Password: Sorry, try again. it asked for a password, and I tried admin, Admin, and Jonathan… they all failed… what password do I need?
🌐
GitHub
github.com › Homebrew › install › issues › 562
Brew Install Leads to Error with Finding Remote Ref · Issue #562 · Homebrew/install
July 24, 2021 - <I got this error message. fatal: Couldn't find remote ref refs/heads/master Error: Fetching /usr/local/Homebrew/Library/Taps/simple2d/homebrew-tap failed!
Author   Homebrew
🌐
GitHub
github.com › Homebrew › brew › issues › 7746
Allow for default branch change on custom tap · Issue #7746 · Homebrew/brew
June 15, 2020 - ==> Unshallowing tugboatqa/tugboat fatal: Couldn't find remote ref refs/heads/master Error: Failure while executing; `git fetch --unshallow` exited with 128.
Author   Homebrew
🌐
Reddit
reddit.com › r/git › "couldn't find remote ref master"
r/git on Reddit: "Couldn't find remote ref master"
January 6, 2021 -

[SOLVED]

Well, it's my first time dealing with this "Git interface". After using commands like:

"git init"

"git remote add origin [link of my repository on Github with that ".git" after its link]"

I tried to make that "pull" command:

"git pull origin master"

however, it's probably not working due to this warning thrown by the terminal:

"fatal: couldn't find remote ref master"

Why is this error happening? How should I fix it?