Homebrew で「error: The following untracked working tree files would be overwritten by merge: Library/Formula/libarchive.rb」というエラーが発生した場合の対応

More than 5 years have passed since last update.

Homebrew の update 時にエラーが発生。

$ brew update

error: The following untracked working tree files would be overwritten by merge:
Library/Formula/libarchive.rb
Please move or remove them before you can merge.
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

この問題が発生した場合は、以下の手順をお試しください。

$ cd /usr/local/Library/Formula

$ git reset --hard FETCH_HEAD
HEAD is now at c784e68 clutter: better homepage

その後、update を実行。

$ brew update

Removing libarchive.rb
Updated Homebrew from c784e68f to c784e68f.
==> Updated Formulae
homebrew/dupes/ab homebrew/dupes/fetchmail homebrew/dupes/whois
homebrew/dupes/ant homebrew/dupes/lapack
homebrew/dupes/diffstat homebrew/dupes/openssh
==> Deleted Formulae
homebrew/dupes/libarchive

無事に update できました。


参考URL