本文翻译自: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/fastcgiLibrary/Aliases/htopLibrary/Aliases/nodejsLibrary/Aliases/ocioLibrary/Aliases/oiioLibrary/Aliases/pgrepLibrary/Aliases/pkillLibrary/Contributions/cmds/brew-beer.rbLibrary/Contributions/cmds/brew-dirty.rbLibrary/Contributions/cmds/brew-graphLibrary/Contributions/cmds/brew-grepLibrary/Contributions/cmds/brew-leaves.rbLibrary/Contributions/cmds/brew-linkapps.rbLibrary/Contributions/cmds/brew-manLibrary/Contributions/cmds/brew-mirror-check.rbLibrary/Contributions/cmds/brew-missing.rbLibrary/Contributions/cmds/brew-pull.rbLibrary/Contributions/cmds/brew-readall.rbLibrary/Contributions/cmds/brew-serverLibrary/Contributions/cmds/brew-services.rbLibrary/Contributions/cmds/brew-switch.rbLibrary/Contributions/cmds/brew-test-bot.commit.html.erbLibrary/Contributions/cmds/brew-test-bot.cssLibrary/Contributions/cmds/brew-test-bot.index.html.erbLibrary/Contributions/cmds/brew-test-bot.rbLibrary/Contributions/cmds/brew-tests.rbLibrary/Contributions/cmds/brew-unpack.rbLibrary/Contributions/cmds/brew-which.rbLibrary/Contributions/install_homebrew.rbLibrary/Formula/abcl.rbLibrary/Formula/abyss.rbLibrary/Formula/akka.rbLibrary/Formula/apollo.rbLibrary/Formula/appledoc.rbLibrary/Formula/arangodb.rbLibrary/Formula/autoconf.rbLibrary/Formula/automake.rbLibrary/Formula/avidemux.rbLibrary/Formula/bind.rbLibrary/Formula/bsdconv.rbLibrary/Formula/bsdmake.rbLibrary/Formula/camellia.rbLibrary/Formula/cbmbasic.rbLibrary/Formula/cdo.rbLibrary/Formula/checkstyle.rbLibrary/Formula/cifer.rbLibrary/Formula/clhep.rbLibrary/Formula/collada-dom.rbLibrary/Formula/crash.rbLibrary/Formula/crossroads.rbLibrary/Formula/css-crush.rbLibrary/Formula/curlftpfs.rbLibrary/Formula/dart.rbLibrary/Formula/dasm.rbLibrary/Formula/dfc.rbLibrary/Formula/di.rbLibrary/Formula/dsniff.rbLibrary/Formula/dupx.rbLibrary/Formula/dwatch.rbLibrary/Formula/eprover.rbLibrary/Formula/ext2fuse.rbLibrary/Formula/ezlupdate.rbLibrary/Formula/f3.rbLibrary/Formula/fastx_toolkit.rbLibrary/Formula/fceux.rbLibrary/Formula/findbugs.rbLibrary/Formula/freerdp.rbLibrary/Formula/funcoeszz.rbLibrary/Formula/fwknop.rbLibrary/Formula/gabedit.rbLibrary/Formula/gbdfed.rbLibrary/Formula/gconf.rbLibrary/Formula/git-encrypt.rbLibrary/Formula/glm.rbLibrary/Formula/gmap-gsnap.rbLibrary/Formula/gnu-arch.rbLibrary/Formula/gnunet.rbLibrary/Formula/gobby.rbLibrary/Formula/gptfdisk.rbLibrary/Formula/griffon.rbLibrary/Formula/grok.rbLibrary/Formula/gtk-chtheme.rbLibrary/Formula/gtkglextmm.rbLibrary/Formula/gtmess.rbLibrary/Formula/hg-flow.rbLibrary/Formula/hqx.rbLibrary/Formula/htop-osx.rbLibrary/Formula/htpdate.rbLibrary/Formula/imap-uw.rbLibrary/Formula/iozone.rbLibrary/Formula/ipbt.rbLibrary/Formula/ipe.rbLibrary/Formula/ispc.rbLibrary/Formula/ispell.rbLibrary/Formula/jigdo.rbLibrary/Formula/jing.rbLibrary/Formula/jless.rbLibrary/Formula/jpeginfo.rbLibrary/Formula/konoha.rbLibrary/Formula/legit.rbLibrary/Formula/libcouchbase.rbLibrary/Formula/libcuefile.rbLibrary/Formula/libextractor.rbLibrary/Formula/libglademm.rbLibrary/Formula/libgtextutils.rbLibrary/Formula/libinfinity.rbLibrary/Formula/libkate.rbLibrary/Formula/libqalculate.rbLibrary/Formula/libqglviewer.rbLibrary/Formula/libreplaygain.rbLibrary/Formula/libtool.rbLibrary/Formula/libvbucket.rbLibrary/Formula/libvo-aacenc.rbLibrary/Formula/libxmi.rbLibrary/Formula/lifelines.rbLibrary/Formula/makeicns.rbLibrary/Formula/mathgl.rbLibrary/Formula/meld.rbLibrary/Formula/mesalib-glw.rbLibrary/Formula/minisat.rbLibrary/Formula/minuit2.rbLibrary/Formula/mobile-shell.rbLibrary/Formula/movgrab.rbLibrary/Formula/mp3cat.rbLibrary/Formula/mpich2.rbLibrary/Formula/mrfast.rbLibrary/Formula/musepack.rbLibrary/Formula/ndiff.rbLibrary/Formula/net6.rbLibrary/Formula/nrpe.rbLibrary/Formula/nuttcp.rbLibrary/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). (强调他们的)。

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

  1. .gitignore和“以下未跟踪的工作树文件将被签出覆盖”

    因此,我在.gitignore文件中添加了一个文件夹. 一旦我做一个git status就会告诉我 # On branch latest nothing to commit (working dire ...

  2. 如何从当前Git工作树中删除本地(未跟踪)文件

    如何从当前工作树中删除未跟踪的本地文件? #1楼 如果未跟踪的目录是它自己的git存储库(例如,子模块),则需要使用-f两次: git clean -d -f -f #2楼 如果需要从特定子目录中删除 ...

  3. Git - ‘假设未改变‘和‘跳过工作树‘之间的区别

    本文翻译自:Git - Difference Between 'assume-unchanged' and 'skip-worktree' I have local changes to a file ...

  4. 在Git中,HEAD,工作树和索引之间有什么区别?

    有人能告诉我在Git中HEAD,工作树和索引之间的区别吗? 据我所知,它们都是不同分支的名称. 我的假设是否正确? 编辑 我找到了这个 单个git存储库可以跟踪任意数量的分支,但是您的工作树只与其中一 ...

  5. Git 2.5增加了工作树、改进了三角工作流、性能等诸多方面

    Git2.5是一个重要的功能版本,其中包括了worktrees.改进过的triangular workflows.更好的性能,以及无数的改进和修复. \\ 工作树(Worktrees) \\ 工作树是 ...

  6. brew update 太慢 Homebrew换源

    刚开始默认安装,使用的是GitHub的源,用过的应该就知道更新下载安装的时候会非常慢. 下面教程是自己换源的操作,也是参考了其他人的做法,同时去清华大学开源软件镜像站上找了下.一般替换国内源有两个,一 ...

  7. 解决vscode在拉取代码报错:在签出前,晴清理存储库工作树。

    vscode git 拉取远程代码时,提示:在签出前,请清理存储库工作树 解决: 1.把当前未提交的修改暂存起来,让仓库还原到最后一次提交的状态 git stash 2.拉取远程仓库的代码,让你现在的 ...

  8. Git常用操作(清除工作区未跟踪文件、保存和恢复进度、打标签)

    git clean 清除工作区未跟踪文件 git clean 命令去除冗余文件或者清理工作目录 git clean -f -d 移除工作目录中所有未追踪的文件以及空的子目录.(-f强制删除) git ...

  9. git 添加未跟踪的文件

    问题描述: 在多个目录下新增了很多文件,但git add时出现大量的文件未跟踪:git push时这些文件并不会被更新到远程库,这是为什么呢? 对比思维: 通过对比发现这次提交和以前有什么不同呢? 1 ...

最新文章

  1. [渣译文] 使用 MVC 5 的 EF6 Code First 入门 系列:MVC程序中实体框架的连接恢复和命令拦截...
  2. HTML5对音频的支持
  3. 上海肯特选用Ultimus 提升企业管理
  4. iOS进阶之正则表达式
  5. rtmp/rtsp/hls公网真正可用的测试地址
  6. html计算天数,Javascript实现简易天数计算器
  7. 一加Ace渲染图曝光:大眼三摄+150W超快闪充
  8. 27. 面向对象程序设计(2)
  9. Linux统计文件夹中文件的个数
  10. 搭建sip软电话环境
  11. QComboBox选项置灰、不可选择、文本颜色(汉字颜色)
  12. oracle 如何考试,oracle考试怎么报名
  13. 如何画出diffusion models的扩散过程示意图?
  14. 演示程序之打游戏 -- 慕司板IAP15
  15. 大疆-2021招聘,我重点关注的岗位
  16. 自动编码(AE)器的简单实现
  17. 嵌入式端音频开发(基础篇)之2021-2022年国内主流语音识别芯片科普(1)
  18. 通过css实现对勾(√)和叉号(×)
  19. Unity - 图形辅助线
  20. 数据治理系统的文献综述

热门文章

  1. python中处理命令行参数命令getopt
  2. C++ vector是什么?应该如何理解
  3. [jQuery]超出容器部分...
  4. 当桌面的快捷方式图标左下角出现一个X(叉)的时候应该怎么去掉
  5. asp.net core2.0中网站发布的时候,怎么样才配置才可以使视图文件不被打包进去?...
  6. python == 字符编码
  7. 轮胎的体积与面积计算
  8. 团队开发之个人博客八(4月27)
  9. HTML+CSS学习笔记(3)- 认识标签(2)
  10. f2fs解析(四)f2fs的extent特性