git - brew 更新 : The following untracked working tree files would be overwritten by merge:

标签 git homebrew

我尝试运行 brew update,但出现错误,提示如果我 merge ,我的本地更改将会丢失。我尝试提交我的本地更改(不记得做了什么,但已经有一段时间了),这让事情变得更糟。

这是输出:

MBP:Library User$ sudo brew update
error: The following untracked working tree files would be overwritten by merge:
    Library/Aliases/fastcgi
    Library/Aliases/htop
    Library/Aliases/nodejs
    Library/Aliases/ocio
    Library/Aliases/oiio
    Library/Aliases/pgrep
    Library/Aliases/pkill
    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-man
    Library/Contributions/cmds/brew-mirror-check.rb
    Library/Contributions/cmds/brew-missing.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.commit.html.erb
    Library/Contributions/cmds/brew-test-bot.css
    Library/Contributions/cmds/brew-test-bot.index.html.erb
    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/install_homebrew.rb
    Library/Formula/abcl.rb
    Library/Formula/abyss.rb
    Library/Formula/akka.rb
    Library/Formula/apollo.rb
    Library/Formula/appledoc.rb
    Library/Formula/arangodb.rb
    Library/Formula/autoconf.rb
    Library/Formula/automake.rb
    Library/Formula/avidemux.rb
    Library/Formula/bind.rb
    Library/Formula/bsdconv.rb
    Library/Formula/bsdmake.rb
    Library/Formula/camellia.rb
    Library/Formula/cbmbasic.rb
    Library/Formula/cdo.rb
    Library/Formula/checkstyle.rb
    Library/Formula/cifer.rb
    Library/Formula/clhep.rb
    Library/Formula/collada-dom.rb
    Library/Formula/crash.rb
    Library/Formula/crossroads.rb
    Library/Formula/css-crush.rb
    Library/Formula/curlftpfs.rb
    Library/Formula/dart.rb
    Library/Formula/dasm.rb
    Library/Formula/dfc.rb
    Library/Formula/di.rb
    Library/Formula/dsniff.rb
    Library/Formula/dupx.rb
    Library/Formula/dwatch.rb
    Library/Formula/eprover.rb
    Library/Formula/ext2fuse.rb
    Library/Formula/ezlupdate.rb
    Library/Formula/f3.rb
    Library/Formula/fastx_toolkit.rb
    Library/Formula/fceux.rb
    Library/Formula/findbugs.rb
    Library/Formula/freerdp.rb
    Library/Formula/funcoeszz.rb
    Library/Formula/fwknop.rb
    Library/Formula/gabedit.rb
    Library/Formula/gbdfed.rb
    Library/Formula/gconf.rb
    Library/Formula/git-encrypt.rb
    Library/Formula/glm.rb
    Library/Formula/gmap-gsnap.rb
    Library/Formula/gnu-arch.rb
    Library/Formula/gnunet.rb
    Library/Formula/gobby.rb
    Library/Formula/gptfdisk.rb
    Library/Formula/griffon.rb
    Library/Formula/grok.rb
    Library/Formula/gtk-chtheme.rb
    Library/Formula/gtkglextmm.rb
    Library/Formula/gtmess.rb
    Library/Formula/hg-flow.rb
    Library/Formula/hqx.rb
    Library/Formula/htop-osx.rb
    Library/Formula/htpdate.rb
    Library/Formula/imap-uw.rb
    Library/Formula/iozone.rb
    Library/Formula/ipbt.rb
    Library/Formula/ipe.rb
    Library/Formula/ispc.rb
    Library/Formula/ispell.rb
    Library/Formula/jigdo.rb
    Library/Formula/jing.rb
    Library/Formula/jless.rb
    Library/Formula/jpeginfo.rb
    Library/Formula/konoha.rb
    Library/Formula/legit.rb
    Library/Formula/libcouchbase.rb
    Library/Formula/libcuefile.rb
    Library/Formula/libextractor.rb
    Library/Formula/libglademm.rb
    Library/Formula/libgtextutils.rb
    Library/Formula/libinfinity.rb
    Library/Formula/libkate.rb
    Library/Formula/libqalculate.rb
    Library/Formula/libqglviewer.rb
    Library/Formula/libreplaygain.rb
    Library/Formula/libtool.rb
    Library/Formula/libvbucket.rb
    Library/Formula/libvo-aacenc.rb
    Library/Formula/libxmi.rb
    Library/Formula/lifelines.rb
    Library/Formula/makeicns.rb
    Library/Formula/mathgl.rb
    Library/Formula/meld.rb
    Library/Formula/mesalib-glw.rb
    Library/Formula/minisat.rb
    Library/Formula/minuit2.rb
    Library/Formula/mobile-shell.rb
    Library/Formula/movgrab.rb
    Library/Formula/mp3cat.rb
    Library/Formula/mpich2.rb
    Library/Formula/mrfast.rb
    Library/Formula/musepack.rb
    Library/Formula/ndiff.rb
    Library/Formula/net6.rb
    Library/Formula/nrpe.rb
    Library/Formula/nuttcp.rb
    Library/Formula/oath-toolkit.
Updating aa07533..3f070ef
Aborting
Error: Failed while executing git pull  origin refs/heads/master:refs/remotes/origin/master

最佳答案

不要忘记获取原点:

cd /usr/local/Homebrew
git fetch origin
git reset --hard origin/master

发生的情况是您正在尝试更新 brew,但 brew 本身不是最新的(可能),通过某些操作系统更新(也可能)更改了权限,或者 brew 略有损坏(不太可能)。由于 brew 本身是一个 git repo,因此您必须将 brew 更新或重置为 master 分支版本。 brew [默认情况下] 位于 /usr/local/Homebrew 文件夹中,因此您

  1. 转到那个文件夹[第一个命令],它也应该更新权限(如果没有见下文)
  2. 获取来源[第二个命令],这意味着更新 brew 远程分支的本地版本
  3. 基于 REMOTE master 分支(也使用您当前的权限)硬重置 [第三条命令]。

如果您处于非 sudo 或管理员配置文件中,您还可以chown第一个命令

sudo chown -R `whoami` /usr/local/Homebrew
cd /usr/local/Homebrew
git reset --hard origin/master

要了解 git reset,请查看 this article .

关于git - brew 更新 : The following untracked working tree files would be overwritten by merge:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10762859/

相关文章:

git - 如何处理未使用的功能分支

Git - 损坏的对象?

git - 如何解决 Git 报告无效的 sha1 指针 0000000000000000000000000000000000000000?

ruby-on-rails - 在 Mac OSX Snow Leopard 上安装 PostgreSQL for Rails 3 - 错误消息

python - 成功安装 Python Homebrew 软件后,运行 `pip` 会得到 'command not found'

c++ - OSX - 用通过 Homebrew 安装的 4.9 替换 gcc 版本 4.2.1

git - 重命名所有旧的分支脚本

git - 无法 pull b/c "You have unstaged changes",但状态显示没有变化

node.js - 现在通过 brew 使用 npm 安装 Node 的方式是什么

php - 如何让 Mac 的终端使用 Brew 的 PHP 版本?