Brew update failed: untracked working tree files would be overwritten by merge
cd $(brew --prefix)
git reset --hard HEAD
brew update
You need to do the following:
cd $(brew --prefix)
rm Library/Formula/argp-standalone.rb
rm Library/Formula/cocot.rb
And then do the
git fetch origin
git reset --hard origin/master
brew update
Basically, to explain a bit more:
cd $(brew --prefix)
tells cd
to change the directory to whatever brew --prefix
will output.
If you try executing brew --prefix
command you should see something in lines of:
brew --prefix
/usr/local
So the command would be in this case an equivalent of cd /usr/local
.
Newer brew
versions have formulae under its installation prefix and Library/Formula/
, so that's where you need to look for those outdated/changed files.
Note, that if you changed those formulae yourself for a particular reason (like pinning a version) this action will revert them back to default ones and may produce unwanted effects.
@TedPennings noted in comments that this worked for him, but his sequence was:
- chown everything to
my_username:admin
, ie,sudo chown -R ted:admin $(brew --prefix)
- run the two git commands above,
git fetch origin
andgit reset --hard origin/master