Homebrew install: Failed during: git fetch origin master:refs/remotes/origin/master -n --depth=1

45,123

Solution 1

After a few hours of research and brute force I learned the issue was due to git not being configured properly. Some articles suggested downgrading your git or reinstalling all together. However, I resolved the issue just by adding the following

git config --global user.email [email protected]

Then remove the cellar and homebrew directories from /usr/local and re-try the installation.

Solution 2

  1. create a file named run.sh
  2. add this:
rm -rf /usr/local/bin/brew
rm -rf /usr/local/share/doc/homebrew
rm -rf /usr/local/share/man/man1/brew.1
rm -rf /usr/local/share/zsh/site-functions/_brew
rm -rf /usr/local/etc/bash_completion.d/brew
rm -rf /usr/local/Homebrew
  1. run the file using sh run.sh

Or, just run all these commands manually one by one.

Solution 3

@ashdaily commands worked for me, addindg sudo on last command and then executing also the @Sinux command too:

rm -rf /usr/local/bin/brew
rm -rf /usr/local/share/doc/homebrew
rm -rf /usr/local/share/man/man1/brew.1
rm -rf /usr/local/share/zsh/site-functions/_brew
rm -rf /usr/local/etc/bash_completion.d/brew
sudo rm -rf /usr/local/Homebrew
rm -rf /opt/homebrew

Solution 4

Steps to fix it on Big Sur (2021):

  1. git config --global user.email [email protected]
  2. Remove the cellar and homebrew directories from /usr/local
  3. Re-try the installation

Works for me on Big Sur.

Solution 5

  • ๐Ÿป New home-brew will installed in /opt/homebrew/ folder.
  • ๐Ÿž If some errors happened at installation you need to reinstall all.
  • ๐Ÿงน Try to clean all trashes with sudo rm -rf /opt/homebrew/ command
  • ๐Ÿš€ Tested and It's worked (12 September 2021)

๐Ÿค” Also, may you need to configure git config --global user.email [email protected]

Share:
45,123
anm
Author by

anm

grad student

Updated on November 12, 2021

Comments

  • anm
    anm over 2 years

    I ran the following command on terminal (Mac El Capitan)

    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    and got the following error message:

    Failed during: git fetch origin master:refs/remotes/origin/master -n --depth=1
    

    Additionally tried:

    sudo chown $(whoami):admin /usr/local && sudo chown -R $(whoami):admin /usr/local
    

    then the two commands above.

    Any idea how to install Homebrew?

    brew is not recognized and ruby version 2.0.0, git version 2.7.4