试图更新自制啤酒与酿造更新我得到以下错误

error: The following untracked working tree files would be overwrittenby merge:     
 Library/Formula/argp-standalone.rb
 Library/Formula/cocot.rb 
Please move or remove them before you can merge. 
Aborting 
Updating e088818..5909e2c 
Error: Failed while executing git pull  origin refs/heads/master:refs/remotes/origin/master

我发现有人在安装Mountain Lion(我本周也安装了Mountain Lion)后遇到了类似的问题。他解释了如何删除错误消息中提到的文件

I removed these files:
$ cd $(brew --prefix)
$ rm cocot.rb
However, removing these files didn't help with the brew update. Instead I had to manually update brew through git:
$ cd $(brew --prefix)
$ git fetch origin
$ git reset --hard origin/master
$ brew update
Already up-to-date.

假设这些说明是正确的(我可能不应该假设),我试着按照这些说明去做

    $ cd $(brew --prefix)
    $ rm cocot.rb

然而,它说“文件不存在”,当我试图rm cota .rb

我不确定的一件事是cd $(brew—prefix)这些是我键入的确切单词还是我必须用一些东西替换前缀?cd是成功的,所以我假设它是正确的——它将我移动到/usr/local,但没有文件要删除。/usr/local的内容为

Cellar              clamXav             git             mysql               var Library             doc             heroku              mysql-5.5.15-osx10.6-x86_64 README.md           etc             include             rvm bin             foreman             lib             share

无论如何,你知道我如何修复“酿造更新”吗?

更新:根据favoretti的说明删除文件后,并尝试chown -R <your_username> $(brew——prefix)/。git,我得到了以下错误运行brew更新

error: The following untracked working tree files would be overwritten by merge:
    Library/Aliases/gperftools
    Library/Aliases/hashdeep
    Library/Aliases/htop
    Library/Aliases/nodejs
    Library/Aliases/ocio
    Library/Aliases/oiio
    Library/Aliases/pgrep
    Library/Aliases/pkill
    Library/Aliases/qt4
    Library/Aliases/twolame
    Library/Aliases/wxwidgets
    Library/Contributions/cmds/brew-aspell-dictionaries
    Library/Contributions/cmds/brew-beer.rb
    Library/Contributions/cmds/brew-dirty.rb
    Library/Contributions/cmds/brew-graph
    Library/Contributions/cmds/brew-grep
    Library/Contributions/cmds/brew-leaves.rb
    Library/Contributions/cmds/brew-linkapps.rb
    Library/Contributions/cmds/brew-ls-taps.rb
    Library/Contributions/cmds/brew-man
    Library/Contributions/cmds/brew-md5-to-sha1
    Library/Contributions/cmds/brew-mirror-check.rb
    Library/Contributions/cmds/brew-pull.rb
    Library/Contributions/cmds/brew-readall.rb
    Library/Contributions/cmds/brew-server
    Library/Contributions/cmds/brew-services.rb
    Library/Contributions/cmds/brew-switch.rb
    Library/Contributions/cmds/brew-test-bot.rb
    Library/Contributions/cmds/brew-tests.rb
    Library/Contributions/cmds/brew-unpack.rb
    Library/Contributions/cmds/brew-which.rb
    Library/Contributions/cmds/git
    Library/Contributions/cmds/svn
    Library/ENV/4.3/apr-1-config
    Library/ENV/4.3/bsdmake
    Library/ENV/4.3/c++
    Library/ENV/4.3/c89
    Library/ENV/4.3/c99
    Library/ENV/4.3/cc
    Library/ENV/4.3/clang
    Library/ENV/4.3/clang++
    Library/ENV/4.3/cpp
    Library/ENV/4.3/g++
    Library/ENV/4.3/gcc
    Library/ENV/4.3/git
    Library/ENV/4.3/i686-apple-darwin11-llvm-g++-4.2
    Library/ENV/4.3/i686-apple-darwin11-llvm-gcc-4.2
    Library/ENV/4.3/ld
    Library/ENV/4.3/llvm-g++
    Library/ENV/4.3/llvm-g++-4.2
    Library/ENV/4.3/llvm-gcc
    Library/ENV/4.3/llvm-gcc-4.2
    Library/ENV/4.3/make
    Library/ENV/4.3/mig
    Library/ENV/4.3/sed
    Library/ENV/4.3/svn
    Library/ENV/4.3/xcrun
    Library/ENV/libsuperenv.rb
    Library/ENV/pkgconfig/leopard/libcrypto.pc
    Library/ENV/pkgconfig/leopard/libcurl.pc
    Library/ENV/pkgconfig/mountain_lion/libcurl.pc
    Library/ENV/pkgconfig/mountain_lion/libexslt.pc
    Library/ENV/pkgconfig/mountain_lion/libxml-2.0.pc
    Library/ENV/pkgconfig/mountain_lion/libxslt.pc
    Library/Formula/abcl.rb
    Library/Formula/abcmidi.rb
    Library/Formula/aiccu.rb
    Library/Formula/akka.rb
    Library/Formula/alac.rb
    Library/Formula/alure.rb
    Library/Formula/appledoc.rb
    Library/Formula/arangodb.rb
    Library/Formula/argp-standalone.rb
    Library/Formula/argtable.rb
    Library/Formula/autopano-sift-c.rb
    Library/Formula/avian.rb
    Library/Formula/avidemux.rb
    Library/Formula/avro-cpp.rb
    Library/Formula/aws-cloudsearch.rb
    Library/Formula/aws-sns-cli.rb
    Library/Formula/backupninja.rb
    Library/Formula/bact.rb
    Library/Formula/bam.rb
    Library/Formula/basex.rb
    Library/Formula/berkeley-db4.rb
    Library/Formula/bind.rb
    Library/Formula/blazeblogger.rb
    Library/Formula/bochs.rb
    Library/Formula/boost149.rb
    Library/Formula/bsdconv.rb
    Library/Formula/bsdmake.rb
    Library/Formula/buildapp.rb
    Library/Formula/bup.rb
    Library/Formula/byacc.rb
    Library/Formula/cadubi.rb
    Library/Formula/camellia.rb
    Library/Formula/casperjs.rb
    Library/Formula/ccextractor.rb
    Library/Formula/cconv.rb
    Library/Formula/cdo.rb
    Library/Formula/cdpr.rb
    Library/Formula/cgvg.rb
    Library/Formula/checkstyle.rb
    Library/Formula/chordii.rb
    Library/Formula/chruby.rb
    Library/Formula/cifer.rb
    Library/Formula/clhep.rb
    Library/Formula/cntlm.rb
    Library/Formula/cocot.rb
    Library/Formula/cogl.rb
    Library/Formula/collada-dom.rb
    Library/Formula/crash.rb
    Library/Formula/crossroads.rb
    Library/Formula/crosstool-ng.rb
    Library/Formula/css-crush.rb
    Library/Formula/csync.rb
    Library/Formula/ctemplate.rb
    Library/Formula/curlftpfs.rb
    Library/Formula/cutter.rb
    Library/Formula/cvsutils.rb
    Library/Formula/darkstat.rb
    Library/Formula/darner.rb
    Library/Formula/dart.rb
    Library/Formula/dasm.rb
    Library/Formula/debianutils.rb
    Library/Formula/dfc.rb
    Library/Formula/dgtal.rb
    Library/Formula/dhcping.rb
    Library/Formula/di.rb
    Library/Formula/dmtx-utils.rb
    Library/Formula/drip.rb
    Library/Formula/dsniff.rb
    Library/Fo
Aborting
Updating e088818..c1fbc29
Error: Failed while executing git pull  origin refs/heads/master:refs/remotes/origin/master

您需要完成以下操作:

cd $(brew --prefix)
rm Library/Formula/argp-standalone.rb
rm Library/Formula/cocot.rb

然后做

git fetch origin
git reset --hard origin/master
brew update

基本上,为了解释得更清楚一点:

cd $(brew --prefix)

告诉CD将目录更改为brew—prefix将输出的任何目录。 如果你尝试执行brew——prefix命令,你应该会看到如下几行:

brew --prefix
/usr/local

因此,在本例中,该命令相当于cd /usr/local。 较新的brew版本在其安装前缀和Library/Formula/下有公式,因此您需要在这里查找那些过时/更改的文件。

请注意,如果您自己出于特定原因(如固定某个版本)更改了这些公式,此操作将使它们恢复到默认值,并可能产生不想要的效果。

@TedPennings在评论中指出,这对他来说很有效,但他的顺序是:

chown -R ted:admin $(brew——prefix) 运行上面的两个git命令,git fetch origin和git reset——hard origin/master


cd $(brew --prefix)
git reset --hard HEAD
brew update

我有一个类似的问题,我的brew包库被下载作为根用户,然后我不能运行brew更新,因为git会抱怨不能合并文件。

解决办法是:-

sudo chown -R <user> /usr/local/Library

我能够通过在这些路径上添加管理组写(和setgid位)权限来解决这个问题:

sudo chmod -R g+ws /usr/local /Library/Caches/Homebrew

s在执行时设置组id,以便下次不同的管理用户更新或升级Homebrew时不会丢失写权限。

这个答案有点不完整,因为当我尝试做brew清理-force时有一个权限问题,当Homebrew试图删除/usr/local/ cellar /中的内容。(不幸的是,我目前无法进一步调查这个问题。)


如果你不介意放弃对公式的潜在修改,重置brew存储库应该是最有效的方法:

$ cd `brew --prefix`
$ git fetch origin
$ git reset --hard origin/master
$ brew cleanup --force
$ brew update

这是由更新代码中的旧错误引起的,该错误早已修复。然而,该漏洞的性质要求您执行以下操作:

cd $(brew --repository)
git reset --hard FETCH_HEAD

如果brew doctor仍然抱怨未提交的修改,也可以运行这个命令:

cd $(brew --repository)    
git clean -fd

另一个选择是使用git stash。

The brew update command performs a git pull, so if there are any changed files (or even file attributes, which happened to me when I changed permissions in the directory recursively) you have to somehow fix the conflicts. Using git stash is one way; it takes any changes and puts them aside so you effectively revert to the last updated repo version. The Homebrew 'location' is by default /usr/local and it installs as a git repository. You can look for a .git folder to see for yourself. I'm writing a homebrew uninstall script to be posted on my GitHub profile soon with more info.


$ cd $(brew --prefix)
$ git clean -fd
$ git reset --hard
$ sudo chown -R `whoami` `brew --prefix`
$ brew update

注意:步骤2和3适用于我,因为我在得到错误之前执行了步骤5和4。在更改文件夹所有者之前的brew更新导致了整个问题。


在更新到El Capitan后,这篇文章帮助了我。在我的情况下,chown没有工作(“zsh:命令没有找到:chown”),所以第1步是添加这一行到我的.zshrc:

export PATH=“$PATH:/usr/sbin”

我已经尝试了上面几个更流行的答案,所以我很确定,当我从博客文章中粘贴关键命令时,git状态已经恢复得很干净了:

sudo chown $(whoami):admin /usr/local &&


sudo chown -R USER /usr/local/bin

注意-用户使用命令,即您的用户名

sudo brew doctor

这应该有用。

1. cd `brew --prefix`
2. git fetch origin
3. git reset --hard origin/master
4. sudo brew update

这种方法可能比其他方法更简单。它包括:

修复了一个git问题,这样您就可以再次委托管理更改了。 不需要手动移动文件或目录。 不需要手动调整文件或目录权限。

步骤(需要解释的人可以做笔记):

cd $(brew --repository)                              // see Note 1 below
git remote add brew https://github.com/Homebrew/brew // see Note 2 below
git pull brew master                                 // promising fast-forward report!
brew update                                          // see Note 3 below 

概述: 据我所知,这个问题的实际原因是回购url的变化。现在已经煮好了,以前也是,少不更事的人。(最新网址:https://github.com/Homebrew/brew)

注意1:第一个命令将您从文件结构中的任何位置引导到正确的目录。对我来说,目录结构与上面显示的其他目录(Mac OS 10.11.16)不同,但是使用这个命令,这些差异应该无关紧要。

注意2:第二个命令将正确的远程url添加到新的别名;我这样做只是为了防止这种方法没有达到我想要的效果,我又需要以前的地址。由于新的远程工作,我将邀请其他人对简单地更改url以起源为别名进行评论。我将很高兴地更新答案,以反映对您有效的方法。

注意3:这个第四个命令得到了理想的结果:它报告了大量的更新,包括特别漂亮的报告“==> migrate HOMEBREW_REPOSITORY to /usr/ localhome brew!”(并强调了这一点)。