brewのUpdateに失敗した場合

久しぶりに brew を update したらコケたのでメモ

$ sudo brew update
error: The following untracked working tree files would be overwritten by merge:
    Library/Formula/dromeaudio.rb
    Library/Formula/geany.rb
    Library/Formula/gerbv.rb
    Library/Formula/gkrellm.rb
    Library/Formula/glade.rb
    Library/Formula/gnumeric.rb
    Library/Formula/gtksourceviewmm.rb
    Library/Formula/gtksourceviewmm3.rb
    Library/Formula/mat.rb
    Library/Formula/sslscan.rb
    Library/Formula/sylpheed.rb
    Library/Formula/tcpurify.rb
    Library/Formula/zenity.rb
    Library/Homebrew/extend/enumerable.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 `brew --prefix`
/usr/local$ sudo git fetch origin
/usr/local$ sudo git reset --hard origin/master
HEAD is now at 1ed1dd1 nesc: update 1.3.6 bottle.

再度実行すると無事に upadte 出来ました。

/usr/local$ sudo brew update
To restore the stashed changes to /usr/local run:
  'cd /usr/local && git stash pop'
Updated 2 taps (homebrew/binary, homebrew/dupes).
==> New Formulae
homebrew/binary/chronograf          homebrew/binary/ngrok2              homebrew/binary/rebol-core          homebrew/binary/txl                 homebrew/dupes/srm
homebrew/binary/kwm                 homebrew/binary/prince              homebrew/binary/rebol-view          homebrew/dupes/bc
==> Updated Formulae
homebrew/binary/adobe-air-sdk       homebrew/binary/perforce-server     homebrew/dupes/grep ✔               homebrew/dupes/nano                 homebrew/dupes/tcpdump
homebrew/binary/adobe-air-sdk-flex  homebrew/binary/rar                 homebrew/dupes/krb5                 homebrew/dupes/ncurses              homebrew/dupes/whois
homebrew/binary/ddptools            homebrew/binary/subgit              homebrew/dupes/lapack               homebrew/dupes/openldap
homebrew/binary/mpress              homebrew/dupes/diffstat             homebrew/dupes/less                 homebrew/dupes/openssh
homebrew/binary/perforce            homebrew/dupes/ed                   homebrew/dupes/libedit              homebrew/dupes/rsync
homebrew/binary/perforce-proxy      homebrew/dupes/file-formula         homebrew/dupes/libpcap              homebrew/dupes/screen
==> Deleted Formulae
homebrew/binary/consul                                      homebrew/binary/exercism                                    homebrew/dupes/gdb

良かった。