Homebrew install: Failed during: git fetch origin master:refs/remotes/origin/master -n --depth=1
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
- create a file named
run.sh
- 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
- 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):
git config --global user.email [email protected]
- Remove the cellar and homebrew directories from
/usr/local
- 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]
Comments
-
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
andruby version 2.0.0
,git version 2.7.4