Just prefix your install command with HOMEBREW_NO_AUTO_UPDATE=1, like this:
HOMEBREW_NO_AUTO_UPDATE=1 brew install somepackage
Source: brew manpage
I just modified /usr/local/bin/brew to add HOMEBREW_NO_AUTO_UPDATE=1 (according to @D Schlachter answer) at the start of the file
You need to reset your Cellar git repo.
cd `brew --cellar`
git reset --hard HEAD
brew upgrade <formula>
That should do it!
You can reset all formulas with:
brew update-reset
The update-reset version of this command resets all formulae to be identical to the contents of their remote repositories, deleting any local changes. It is only used as a last-resort effort to fix a problem (it’s like unplugging Homebrew and plugging it back in).
Update 10/11/2020 to reflect the latest brew changes.
Brew already provide a command to uninstall itself (this will remove everything you installed with Homebrew):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
If you failed to run this command due to permission (like run as second user), run again with sudo
Then you can install again:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Process is to clean up and then reinstall with the following commands:
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install )"
Notes:
- Always check
curl | bash (or ruby)commands before running them - http://brew.sh/ (for installation notes)
- https://raw.githubusercontent.com/Homebrew/install/master/install (for clean up notes, see "Homebrew is already installed")
It could be downloading something large and taking a long time. Try running the following so you can see the download progress:
brew update --debug --verbose
ctrl + cto exit the hanging upgrade.- Run
brew doctor. It prompted me to - run
brew cleanupto clean up false symlinks. Then I - ran
brew doctoragain and it prompted me - to install xcode CLT via
the command
sudo xcode-select --install. - Finally
brew updateworked.