Brew update failed: untracked working tree files would be overwritten by merge
试图用
1 2 3 4 5 6 7 | 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之后遇到了类似问题的人发现了一篇博文(我本周也做过)。他解释了他是如何删除错误消息中提到的文件的
1 2 3 4 5 6 7 8 9 | 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. |
假设这些指令是正确的(我可能不应该假设),我试着按照这些说明进行操作
1 2 | $ cd $(brew --prefix) $ rm cocot.rb |
但是,当我尝试使用roc cocot.rb时,它说'文件不存在'
我不确定的一件事是
1 | 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 |
无论如何,你知道如何修复'brew update'吗?
更新:根据favoretti的说明删除文件并尝试
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | 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 |
您需要执行以下操作:
1 2 3 | cd $(brew --prefix) rm Library/Formula/argp-standalone.rb rm Library/Formula/cocot.rb |
然后做
1 2 3 | git fetch origin git reset --hard origin/master brew update |
基本上,要解释一下:
1 | cd $(brew --prefix) |
告诉
如果您尝试执行
1 2 | brew --prefix /usr/local |
因此,在这种情况下,命令将等效于
较新的
请注意,如果您因特定原因(例如固定版本)而自行更改了这些公式,则此操作会将其还原为默认值,并可能产生不需要的效果。
@TedPennings在评论中指出这对他有用,但他的顺序是:
1 2 3 | cd $(brew --prefix) git reset --hard HEAD brew update |
这是由
1 2 | cd $(brew --repository) git reset --hard FETCH_HEAD |
如果
1 2 | cd $(brew --repository) git clean -fd |
1 2 3 4 5 | $ cd $(brew --prefix) $ git clean -fd $ git reset --hard $ sudo chown -R `whoami` `brew --prefix` $ brew update |
注意:第2步和第3步对我有用,因为我在收到错误之前在4之前执行了第5步。更改文件夹所有者之前的brew更新导致了整个问题。
我有一个类似的问题,我的brew包库作为root用户下载,然后我无法运行brew更新,因为git会抱怨无法合并文件。
解决方案是: -
1 | sudo chown -R <user> /usr/local/Library |
如果您不介意放弃对可能已应用的公式的潜在修改,则重置brew存储库应该是最有效的方法:
1 2 3 4 5 | $ cd `brew --prefix` $ git fetch origin $ git reset --hard origin/master $ brew cleanup --force $ brew update |
通过在这些路径中添加admin group write(和setgid bit)权限,我能够在我的机器上修复此问题:
1 | sudo chmod -R g+ws /usr/local /Library/Caches/Homebrew |
s在执行时设置组ID,以便下次其他管理员用户更新或升级Homebrew时不会丢失写入权限。
这个答案有点不完整,因为当我尝试执行
这种方法可能比某些方法简单。它涉及:
- 修复git问题,以便您可以再次委托对其进行更改管理。
- 没有手动移动文件或目录。
- 没有手动调整文件或目录权限。
步骤(有需要解释的人的笔记):
1 2 3 4 | 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 |
概述:
据我所知,这个问题的实际原因是回购网址的变化。它现在是
注1:第一个命令将您从文件结构中的任何位置带到正确的目录。对我来说,目录结构与上面显示的不同(Mac OS 10.11.16),但是使用此命令,这些差异无关紧要。
注2:第二个命令将正确的远程URL添加到新别名中;我这样做是为了防止这种方法没有达到我想要的效果,我再次需要以前的地址。由于新的远程工作,我将邀请其他人评论只是通过原点更改别名的URL。我很乐意更新答案,以反映对您有用的内容。
注3:这第四个命令具有完全理想的结果:它报告大量更新,包括"==>迁移的HOMEBREW_REPOSITORY到/ usr / local / Homebrew!"的特别好的报告。 (强调他们的)。
1 | sudo chown -R USER /usr/local/bin |
注意 - 对于USER使用命令,即您的用户名
1 | sudo brew doctor |
另一种选择是使用
brew update命令执行
这应该工作。
1 2 3 4 | 1. cd `brew --prefix` 2. git fetch origin 3. git reset --hard origin/master 4. sudo brew update |
这篇文章在更新到El Capitan之后帮助了我。就我而言,
我已经尝试了上面几个比较流行的答案,所以我很确定