I kept getting various homebrew errors while doing brew update.

Error: Failed while executing git pull origin refs/heads/master:refs/remotes/origin/master

error: unable to unlink old ‘bin/brew’ (Permission denied)

brew update fails ‘unable to unlink old ‘.gitignore’

I did a brew doctor, and got tons of warnings and errors. Um… let’s just do a clean re-install… I don’t have time to troubleshoot all that.

If you want to do a clean install, here it is, assuming your brew –prefix is /usr/local.

cd /usr/local
sudo rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then finally do a brew doctor to take care of minor issues perhaps due to your environment settings.

EDIT (Oct 1st, 2014): changed the old command from ruby -e “$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" to ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)". The new command is from http://brew.sh/. Thanks guizm0, Aki, and Henrik. =)