尝试更新brew包管理器时出错
我尝试更新brew:
sudo brew update
但出现此错误:
错误:您对以下文件的本地更改将被合并覆盖:
列出很多文件
错误:执行 git pull 时失败 http://github.com/mxcl/homebrew.git大师
知道出了什么问题吗?
I tried to update brew:
sudo brew update
But I got this error:
error: Your local changes to the following files would be overwritten by merge:
Listing a lot of files
Error: Failed while executing git pull http://github.com/mxcl/homebrew.git master
Any idea what is going wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
Homebrew 中有一个错误,几天前已修复。要修复该错误,您可以在 Homebrew 安装中运行 git reset --hard FETCH_HEAD 。由于这不会修复已被视为已修改的文件,您还可以运行 git checkout Library 来用最新文件替换您的结账。 (这会擦除所有编辑内容,因此请对您所做的任何内容采取适当的措施。)
There was a bug in Homebrew that was fixed just a few days ago. To fix the bug you can run
git reset --hard FETCH_HEAD
inside your Homebrew installation. Since that won't fix files that are already seen as modified you can also rungit checkout Library
to replace your checkout with the latest files. (That wipes all edits so take appropriate measures with any you made.)接受的答案是正确的但不完整。如果您收到错误
错误:以下未跟踪的工作树文件将被合并覆盖:
然后转到您的终端并运行这些命令
然后
然后
这应该让一切按顺序进行。然后运行
The accepted answer is correct but incomplete. If you are getting the error of
error: The following untracked working tree files would be overwritten by merge:
Then go to your terminal and run these commands
Then
Then
That should get everything in order. Then run
让我添加:
cd /usr/local/git
然后运行 git reset --hard FETCH_HEAD
Let me add:
cd /usr/local/git
and then run
git reset --hard FETCH_HEAD
转到您的终端并运行这些命令
go to your terminal and run these commands
对于使用 OS X El Capitan 的用户来说,您的问题可能是系统完整性保护。
如果
/usr/local
已存在,请在终端中运行以下命令:如果
/usr/local
不存在:首先,尝试创建
/usr/local< /code> 正常方式:
如果您看到权限问题,请尝试:
csrutil disable
csrutil enable
For those of you using OS X El Capitan, your problem may be System Integrity Protection.
If
/usr/local
exists already, run the following in Terminal:If
/usr/local
does not exist:First, try to create
/usr/local
the normal way:If you see permission issues instead try:
csrutil disable
csrutil enable
出于某种原因(或者至少我不明白),
/usr/local
中的存储库(即brew 安装!)丢失了其远程存储库。因此,git reset
和git pull
都不起作用,并且肯定没有brew update
起作用。你怎么知道这件事发生了?检查
/usr/local/.git/config
是否有类似下面的行:如果没有则执行如下操作:
Out of no reason (or at least no one I'd understand) the repository in
/usr/local
(which is the brew install!) lost its remote repository. So, neither agit reset
nor agit pull
and for sure nobrew update
would work.How do you know that happened? Check
/usr/local/.git/config
whether there are some lines like the following:If not do as follows: