git Homebrew 更新失败:“请在合并之前提交您的更改或隐藏它们”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17868956/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Homebrew update fail: "Please, commit your changes or stash them before you can merge"
提问by burger
I am running:
我在跑步:
brew update
And I get an error:
我收到一个错误:
error: Your local changes to the following files would be overwritten by merge:
samtools.rb
Please, commit your changes or stash them before you can merge.
Aborting
It turns out this is a well known error. In fact, it's mentioned on the Homebrew wiki:
事实证明这是一个众所周知的错误。事实上,它在Homebrew wiki上提到:
After running brew update, you receive a git error warning about untracked files or local changes that would be overwritten by a checkout or merge, followed by a list of files inside your Homebrew installation.
This is caused by an old bug in in the update code that has long since been fixed. However, the nature of the bug requires that you do the following:
cd $(brew --repository)
git reset --hard FETCH_HEAD
If brew doctor still complains about uncommitted modifications, also run this command:
cd $(brew --repository)/Library
git clean -fd
I followed those instructions and am still seeing the same error. What is wrong?
我遵循了这些说明,但仍然看到相同的错误。怎么了?
回答by burger
I was able to resolve the issue myself.
我自己解决了这个问题。
What tipped me off is running "git status" did not show that file.
提示我的是运行“git status”没有显示该文件。
Instead of using the common solution:
而不是使用常见的解决方案:
cd $(brew --repository)
git reset --hard FETCH_HEAD
I had to do:
我必须做:
cd [directory of the file in question]
git reset --hard FETCH_HEAD
That resolved the problem.
那解决了问题。
回答by javabrain
This fixed it for me:
这为我修复了它:
https://stackoverflow.com/a/20138806
https://stackoverflow.com/a/20138806
cd `brew --prefix`
git fetch origin
git reset --hard origin/master
回答by michael
I had this problem after manually correcting a URL in the numpy formula. I was able to correct this later by:
在 numpy 公式中手动更正 URL 后,我遇到了这个问题。后来我能够通过以下方式纠正这个问题:
cd /usr/local/Library/Taps/homebrew/homebrew-python
git checkout -- numpy.rb
brew update