我试图运行brew update,我得到一个错误,如果我合并,我的本地更改将丢失.我尝试了我的本地更改(不记得制作任何,但它已经有一段时间了),这让事情变得更糟.
这是输出:
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
Run Code Online (Sandbox Code Playgroud)
chr*_*ina 737
别忘了取出原点!!!
$ cd /usr/local
$ git fetch origin
$git reset --hard origin/master
解释,对于有兴趣的人:
发生的事情是你正在尝试更新brew,但brew本身要么不是最新的(可能),通过某些操作系统更新(也可能)有权限更改,或brew稍微损坏(不太可能).由于brew本身就是一个git repo,你必须更新或重置brew到master分支版本.brew [默认]位于/usr/local文件夹中,所以你
chown如果你是非sudo或管理员资料
$ sudo chown -R `whoami` /usr/local
$ cd /usr/local
$,你也可以使用第一个命令git reset --hard origin/master
要了解git reset,请查看本文.
Joe*_*way 107
几个星期前,我有一个类似的问题试图更新旧的自制软件安装.这样做:
git reset --hard origin/master
Run Code Online (Sandbox Code Playgroud)
在/usr/local固定对我来说.
似乎其他人也有这个问题.您是否查看过此处提出的任何解决方法?
fur*_*ins 11
我正在添加我的个人经验,因为它似乎比2012年的建议更安全一些:
brew doctor.如果您收到以下警告:
Warning: The /usr/local directory is not writable.
Run Code Online (Sandbox Code Playgroud)
跑:
sudo chown -R `whoami` /usr/local
Run Code Online (Sandbox Code Playgroud)
修复权限问题(Chris Frisina也提出).最终brew doctor再次运行以确保警告消失.
现在,你应该有一个
Warning: You have uncommitted modifications to Homebrew
Run Code Online (Sandbox Code Playgroud)
这可能是因为解决了
cd /usr/local/Library && git stash && git clean -d -f
Run Code Online (Sandbox Code Playgroud)
正如Dr.Brew博士所建议的那样.该命令存储未提交的修改,因此您可以返回并在需要时恢复它们.它似乎比git reset --hard origin/master我更安全.
如果您愿意,请查看官方故障排除指南,如果此处和其他SO用户建议的步骤无法解决您的问题.