[Mac] Homebrew update 出現 git pull 錯誤訊息

[Mac] Homebrew update 出現 git pull 錯誤訊息

今天又遇到了 Homebrew update 失敗的問題…

是一個蠻常遇見的問題,只不過這次的錯誤訊息更長了:

testuser@localhost ~ $ brew update
error: Your local changes to the following files would be overwritten by merge:
.gitignore
.yardopts
CODEOFCONDUCT.md
CONTRIBUTING.md
LICENSE.txt
Library/Contributions/brew_bash_completion.sh
Library/Contributions/brew_fish_completion.fish
Library/Contributions/brew_zsh_completion.zsh
Library/Contributions/example-formula.rb
Library/ENV/4.3/cc
Library/ENV/4.3/pod2man
Library/Formula/aalib.rb
Library/Formula/abcde.rb
Library/Formula/acpica.rb
Library/Formula/activemq-cpp.rb
Library/Formula/adns.rb
Library/Formula/adobe-air-sdk.rb
Library/Formula/afflib.rb
Library/Formula/aget.rb
Library/Formula/aha.rb
Library/Formula/aircrack-ng.rb
Library/Formula/akka.rb
Library/Formula/alpine.rb
Library/Formula/amap.rb
Library/Formula/analog.rb
Library/Formula/android-ndk.rb
Library/Formula/android-platform-tools.rb
Library/Formula/ansible.rb
Library/Formula/ansifilter.rb
Library/Formula/ape.rb
Library/Formula/apib.rb
Library/Formula/apngasm.rb
Library/Formula/app-engine-java-sdk.rb
Library/Formula/arangodb.rb
Library/Formula/argp-standalone.rb
Library/Formula/argus-clients.rb
Library/Formula/argus.rb
Library/Formula/aria2.rb
Library/Formula/arp-scan.rb
Library/Formula/artifactory.rb
Library/Formula/asciidoc.rb
Library/Formula/asn1c.rb
Library/Formula/aspell.rb
Library/Formula/assimp.rb
Library/Formula/astyle.rb
Library/Formula/at-spi2-atk.rb
Library/Formula/at-spi2-core.rb
Library/Formula/atf.rb
Library/Formula/atk.rb
Library/Formula/ats2-postiats.rb
Library/Formula/aubio.rb
Library/Formula/augeas.rb
Library/Formula/autoconf-archive.rb
Library/Formula/autojump.rb
Library/Formula/autossh.rb
Library/Formula/avfs.rb
Library/Formula/avian.rb
Library/Formula/avidemux.rb
Library/Formula/aws-elasticbeanstalk.rb
Library/Formula/awscli.rb
Library/Formula/babl.rb
Library/Formula/bash-git-prompt.rb
Library/Formula/bazaar.rb
Library/Formula/bdw-gc.rb
Library/Formula/berkeley-db.rb
Library/Formula/berkeley-db4.rb
Library/Formula/betty.rb
Library/Formula/bfg.rb
Library/Formula/bibtex2html.rb
Library/Formula/bind.rb
Library/Formula/bison.rb
Library/Formula/bitlbee.rb
Library/Formula/boost-build.rb
Library/Formula/boost.rb
Library/Formula/boot2docker.rb
Library/Formula/botan.rb
Library/Formula/bpm-tools.rb
Library/Formula/bro.rb
Library/Formula/bsdmake.rb
Library/Formula/cabal-install.rb
Library/Formula/cairo.rb
Library/Formula/cairomm.rb
Library/Formula/camlp5.rb
Library/Formula/capnp.rb
Library/Formula/capstone.rb
Library/Formula/cassandra.rb
Library/Formula/ccache.rb
Library/Formula/ceylon.rb
Library/Formula/cfengine.rb
Library/Formula/cgal.rb
Library/Formula/checkstyle.rb
Library/Formula/chibi-scheme.rb
Library/Formula/chmlib.rb
Library/Formula/chromedriver.rb
Library/Formula/chruby.rb
Library/Formula/chuck.rb
Library/Formula/clamav.rb
Library/Formula/clib.rb
Library/Formula/cliclick.rb
Library/Formula/cln.rb
Library/Formula/cloog.rb
Library/Formula/closure-compiler.rb
Library/Formula/clutter-gtk.rb
Library/Formula/clutter.rb
Library/Formula/cmake.rb
Library/Formula/coccinelle.rb
Library/Formula/cogl.rb
Library/Formula/confuse.rb
Library/Formula/cookiecutter.rb
Library/Formula/coq.rb
Library/Formula/coreutils.rb
Library/Formula/couchpotatoserver.rb
Library/Formula/cpanminus.rb
Library/Formula/cppcheck.rb
Library/Formula/cppunit.rb
Library/Formula/cracklib-words.rb
Library/Formula/cracklib.rb
Library/Formula/crosstool-ng.rb
Library/Formula/curl.rb
Library/Formula/czmq.rb
Library/Formula/d-bus.rb
Library/Formula/daq.rb
Library/Formula/dar.rb
Library/Formula/datomic.rb
Library/Formula/davix.rb
Library/Formula/dbus-glib.rb
Library/Formula/dcmtk.rb
Library/Formula/dfu-util.rb
Library/Formula/dgtal.rb
Library/Formula/dialog.rb
Library/Formula/direnv.rb
Library/Formula/disco.rb
Library/Formula/djvulibre.rb
Library/Formula/dnsmasq.rb
Library/Formula/dnsrend.rb
Library/Formula/docbook-xsl.rb
Library/Formula/docbook.rb
Library/Formula/docker.rb
Library/Formula/dockutil.rb
Library/Formula/doitlive.rb
Library/Formula/dos2unix.
error: The following untracked working tree files would be overwritten by merge:
Library/Aliases/actor-framework
Library/Aliases/libcaf
Library/Formula/aescrypt-packetizer.rb
Library/Formula/aptly.rb
Library/Formula/blucat.rb
Library/Formula/camlp4.rb
Library/Formula/chinadns-c.rb
Library/Formula/closure-linter.rb
Library/Formula/euler-py.rb
Library/Formula/fibjs.rb
Library/Formula/finatra.rb
Library/Formula/flow.rb
Library/Formula/gammaray.rb
Library/Formula/gdnsd.rb
Library/Formula/gifify.rb
Library/Formula/gnatsd.rb
Library/Formula/groovysdk.rb
Library/Formula/hardlink-osx.rb
Library/Formula/hashcash.rb
Library/Formula/hh.rb
Library/Formula/idris.rb
Library/Formula/jenv.rb
Library/Formula/jsoncpp.rb
Library/Formula/lastpass-cli.rb
Library/Formula/libiomp.rb
Library/Formula/libsoxr.rb
Library/Formula/makefile2graph.rb
Library/Formula/megatools.rb
Library/Formula/mitie.rb
Library/Formula/mvnvm.rb
Library/Formula/nailgun.rb
Library/Formula/odt2txt.rb
Library/Formula/osquery.rb
Library/Formula/pinentry-mac.rb
Library/Formula/pulse.rb
Library/Formula/pup.rb
Library/Formula/rbenv-bundler-ruby-version.rb
Library/Formula/simple-amqp-client.rb
Library/Formula/skinny.rb
Library/Formula/smali.rb
Library/Formula/snow.rb
Library/Formula/sslmate.rb
Library/Formula/stlink.rb
Library/Formula/sword.rb
Library/Formula/synscan.rb
Library/Formula/tutum.rb
Library/Formula/ucommon.rb
Library/Formula/with-readline.rb
Library/Formula/yash.rb
Library/Homebrew/README.md
Library/Homebrew/requirements/tuntap_dependency.rb
Library/Homebrew/requirements/unsigned_kext_requirement.rb
Library/Homebrew/test/fixtures/test.gif
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

 

之前看到這類的錯誤訊息,想說就照著上面寫的,

把列出來的那些檔案都砍掉,再做一次 brew update,但通常效果不彰…

 

在 Stackoverflow: Brew update failed 這邊看到網友有一些作法,

試了一下,老實說還不確定是否真的問題解決了,

只是目前 brew update 的確是沒有錯誤訊息了~

 

1. 開啟 Terminal,切換到 brew 的目錄

在我的機器上執行 brew –prefix 會印出 /usr/local,

因此事實上就是切換到 /usr/local 目錄:

cd $(brew --prefix)

 

2. 執行 git fetch origin

testuser@localhost /usr/local $ git fetch origin
remote: Counting objects: 360, done. remote: Compressing objects: 100% (169/169), done. remote: Total 360 (delta 133), reused 360 (delta 133) Receiving objects: 100% (360/360), 131.85 KiB | 176.00 KiB/s, done. Resolving deltas: 100% (133/133), done. From https://github.com/Homebrew/homebrew * [new branch] gh-pages -> origin/gh-pages * [new branch] go -> origin/go

 

3. 執行 git reset –hard origin/master

testuser@localhost /usr/local $ git reset --hard origin/master
HEAD is now at f235f15 syncthing: update 0.10.14 bottle.

 

4. 最後再執行一次 brew update

也可以順便執行一下 brew upgrade,看看現在的套件是否可升級到新版的:

testuser@localhost /usr/local $ brew update
Already up-to-date.
testuser@localhost /usr/local $ brew upgrade
==> Upgrading 22 outdated packages, with result:
cairo 1.14.0, freetype 2.5.4, gettext 0.19.4, glib 2.42.1, gnupg 1.4.18_1, gnutls 3.3.11, gtk+ 2.24.25, harfbuzz 0.9.37, libgpg-error 1.17, libotr 4.1.0, libpng 1.6.16, libtool 2.4.4, node 0.10.35, openssl 1.0.1j_1, pcre 8.36, protobuf 2.6.1, python 2.7.9, sqlite 3.8.7.4, ssh-copy-id 6.7p1, tomcat 8.0.15, vala 0.26.1, yara 3.2.0

 

之所以說不確定是否上述已經完全解決問題,

是因為之前解掉的 Homebrew 問題也有再出現過,

所以這次得等到過一陣子再執行 brew update 也都沒有問題,

才能確認解法可用囉~

 

(本頁面已被瀏覽過 298 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料