まめ畑

ゆるゆると書いていきます

homebrewのupdateが失敗した時

いつものように、brew updateを実行したところ、

#brew update                                                                                                                                                          
error: The following untracked working tree files would be overwritten by merge:
        Library/Aliases/fastcgi
        Library/Formula/ape.rb
        Library/Formula/apollo.rb
        Library/Formula/arp-scan.rb
        Library/Formula/autoconf.rb
        Library/Formula/autojump.rb
        Library/Formula/automake.rb
        Library/Formula/blackbox.rb
        Library/Formula/bro.rb
        Library/Formula/cbmbasic.rb
        Library/Formula/conserver.rb
        Library/Formula/ecm.rb
…
Please move or remove them before you can merge.
Aborting
Updating 8f3d373..6bd2df7
Error: Failed while executing git pull  origin refs/heads/master:refs/remotes/origin/master

こんな感じのエラーが出てしまってupdateが出来なくなったけど、以下の様な感じで治ったのでメモ。

cd `brew --prefix`
git remote add origin https://github.com/mxcl/homebrew.git  #いらないはず
git fetch origin                                                                                                                                                          
git reset --hard origin/master
brew update