Don't forget to fetch the origin:
cd /usr/local/Homebrew
git fetch origin
git reset --hard origin/master
What happens is that you are trying to update brew, but brew itself is either not up to date (likely), there is a permissions change via some OS update (also likely), or brew is slightly corrupt (unlikely). Since brew itself is a git repo, you have to update or reset brew to the master branch version. brew [by default] is located in the /usr/local/Homebrew
folder, so you
- Go to that folder [first command] which also should update permissions (if not see below)
- Fetch the origin [second command] which means to update your LOCAL version of the remote branch of brew
- Hard reset [3rd command] based on the REMOTE master branch (which also uses your current permissions).
You can also chown
the first command if you are in a non sudo or admin profile
sudo chown -R `whoami` /usr/local/Homebrew
cd /usr/local/Homebrew
git reset --hard origin/master
To understand git reset, take a look at this article.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…