brew update:以下未跟踪的工作树文件将被合并覆盖:

当尝试更新Homebrew时遇到'未跟踪的工作树文件将被合并覆盖'的错误,可以通过一系列Git操作来解决。首先切换到Homebrew所在的目录,然后取出原点更新权限,最后进行硬重置。如果遇到权限问题,可以使用sudo chown -R $(whoami) /usr/local/Homebrew来修复。此外,还可以考虑使用git stash保存未提交的修改,以避免丢失本地更改。
摘要由CSDN通过智能技术生成

本文翻译自:brew update: The following untracked working tree files would be overwritten by merge:

I tried to run brew update and I get an error about my local changes would be lost if I merged. 我尝试运行brew update ,如果合并,我会收到有关本地更改的错误。 I tried committing my local changes (don't remember making any, but it's been awhile), and that made things worse. 我尝试了我的本地更改(不记得制作任何,但它已经有一段时间了),这使事情变得更糟。

Here's the output: 这是输出:

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

#1楼

参考:https://stackoom.com/question/j9uV/brew-update-以下未跟踪的工作树文件将被合并覆盖


#2楼

I had a similar issue a couple weeks ago trying to update an old homebrew install. 几个星期前,我有一个类似的问题试图更新旧的自制软件安装。 Doing this: 这样做:

git reset --hard origin/master

in /usr/local fixed it for me. /usr/local为我修复了它。

It seems like other folks have had this issue too. 似乎其他人也有这个问题。 Have you looked over any of the proposed workarounds here ? 您是否查看了此处提出的任何解决方法?


#3楼

Don't forget to fetch the origin!!! 别忘了取出原点!!!

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

Explanation, for those interested: 解释,对于有兴趣的人:

What happens is that you are trying to update brew, but brew itself is either not up to date (likely), there is a permissions change via some OS update (also likely), or brew is slightly corrupt (unlikely). 发生的事情是你正在尝试更新brew,但brew本身要么不是最新的(可能),通过某些操作系统更新(也可能)有权限更改,或brew稍微损坏(不太可能)。 Since brew itself is a git repo, you have to update or reset brew to the master branch version. 由于brew本身就是一个git repo,你必须更新或重置brew到master分支版本。 brew [by default] is located in the /usr/local folder, so you brew [默认]位于/usr/local文件夹中,所以你

  1. Go to that folder [first command] which also should update permissions (if not see below) 转到那个也应该更新权限的文件夹[first command](如果没有看到)
  2. Fetch the origin [second command] which means to update your LOCAL version of the remote branch of brew 获取原点[第二个命令],这意味着更新brew的远程分支的LOCAL版本
  3. Hard reset [3rd command] based on the REMOTE master branch (which also uses your current permissions). 硬重置[第3个命令]基于REMOTE主分支(也使用您当前的权限)。

You can also chown the first command if you are in a non sudo or admin profile 您也可以chown的第一个命令,如果你是在非须藤或管理员的个人资料
$ sudo chown -R `whoami` /usr/local $ sudo chown -R `whoami` /usr/local
$ cd /usr/local $ cd /usr/local
$ git reset --hard origin/master $ git reset --hard origin/master

To understand git reset, take a look at this article . 要了解git reset,请查看本文


#4楼

I'm adding my personal experience, since it seems a little safer than what proposed in 2012: 我正在添加我的个人经验,因为它似乎比2012年的建议更安全一些:

  1. Run brew doctor . brew doctor
  2. If you get the following warning: 如果您收到以下警告:

     Warning: The /usr/local directory is not writable. 

    run: 跑:

     sudo chown -R `whoami` /usr/local 

    to fix the permissions problems (as suggested also by Chris Frisina). 修复权限问题(Chris Frisina也提出)。 Eventually run brew doctor again to ensure yourself that the warning is gone. 最后再次运行brew doctor以确保警告消失。

  3. Now, you should have a 现在,你应该有一个

     Warning: You have uncommitted modifications to Homebrew 

    that may bey solved by 这可能是因为解决了

     cd /usr/local/Library && git stash && git clean -d -f 

    as suggested by Dr.Brew itself. 正如Dr.Brew博士所建议的那样。 The command stashes the uncommitted modifications so you could go back and recover them if needed. 该命令存储未提交的修改,因此您可以返回并在需要时恢复它们。 It seemed safer than git reset --hard origin/master to me. 它似乎比git reset --hard origin/master更安全 - git reset --hard origin/master给我。

  4. If you wish, check the official troubleshooting guide if the steps suggested here and by other SO users does not solve your problem. 如果您愿意,请查看官方故障排除指南,如果此处和其他SO用户建议的步骤无法解决您的问题。


#5楼

Similar answer but if you have files that are no longer tracked you need additional step so from /usr/local run 类似的答案,但如果你有不再跟踪的文件,你需要额外的步骤,所以从/usr/local运行

git fetch origin
git clean -f
git reset --hard origin/master

#6楼

This approach may be simpler than some. 这种方法可能比某些方法简单。 It involves: 它涉及:

  • fixing a git issue so you can delegate management of changes to it again. 修复git问题,以便您可以再次委托对其进行更改管理。
  • no manual moves of files or directories. 没有手动移动文件或目录。
  • no manual adjustments of file or directory permissions. 没有手动调整文件或目录权限。

Steps (with notes for those who want explanations): 步骤(有需要解释的人的笔记):

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 

Overview: 概述:
From what I can tell, the actual cause of this issue is a change in the repo url. 据我所知,这个问题的实际原因是回购网址的变化。 It's now brew and was brew.git . 它现在正在brew并且是brew.git (Full up-to-date url: https://github.com/Homebrew/brew ) (完整的最新网址: https//github.com/Homebrew/brew

Note 1: This first command takes you from anywhere in your file structure to the correct directory. 注1:第一个命令将您从文件结构中的任何位置带到正确的目录。 The directory structure is different for me than what others show above (Mac OS 10.11.16), but with this command, those differences should not matter. 对我来说,目录结构与上面显示的不同(Mac OS 10.11.16),但是使用此命令,这些差异无关紧要。

Note 2: This second command adds the correct remote url to a new alias; 注2:第二个命令将正确的远程URL添加到新别名中; I did so just in case this approach didn't accomplish what I wanted and I needed the previous address again. 我这样做是为了防止这种方法没有达到我想要的效果,我再次需要以前的地址。 Since the new remote worked, I'll invite someone else to comment on simply changing the url aliased by origin. 由于新的远程工作,我将邀请其他人评论只是通过原点更改别名的URL。 I'll happily update the answer to reflect what worked for you. 我很乐意更新答案,以反映对您有用的内容。

Note 3: This forth command has exactly the desired result: it reports a large number of updates, including the particularly nice report of "==> Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew!" 注3:这第四个命令具有完全理想的结果:它报告大量更新,包括“==>迁移的HOMEBREW_REPOSITORY到/ usr / local / Homebrew!”的特别好的报告。 (emphasis theirs). (强调他们的)。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值