A lot of times, when I update brew, I need to make a prayer before updating. Now when I every time I update, I do the following. And I haven't had a problem since.
Resetting brew formulas to be identical to their repositories.
brew update-reset
Then, as usual, update, upgrade, and cleanup.
brew update
brew upgrade
brew cleanup
In case of a problem, I run brew doctor
, but I haven't had to do it since running update-reset.