When I ran:
brew update
I got a message saying it initialized an empty repository in /usr/local/.git/, then I got this error:

cd /usr/localgit statusgit status til it's cleanbrew updategit stash changes. Then after you're done updating, run git stash pop to restore your custom modifications
sudo chown -R yourusername:admin /usr/local/.git
Oct 19, 2016 at 11:56
As of 2021 you can simply use brew update which updates homebrew itself.
brew update, first run: git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow These commands may take a few minutes to run due to the large size of the repositories. This restriction has been made on GitHub's request because updating shallow clones is an extremely expensive operation due to the tree layout and traffic of Homebrew/homebrew-core and Home.....
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow Before running brew update
Nov 9, 2021 at 11:09
Alternatively you could update brew by installing it again. (Think I did this as El Capitan changed something)
Note: this is a heavy handed approach that will remove all applications installed via brew!
Try to install brew a fresh and it will tell how to uninstall.
At original time of writing to uninstall:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Edit: As of 2020 to uninstall:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
brew
Oct 11, 2016 at 7:11
git init; git fetch https://github.com/mxcl/homebrew.git master; git reset --hard FETCH_HEAD; brew update.