68

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:

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?

4

3 回答 3

107

我能够自己解决问题。

提示我的是运行“git status”没有显示该文件。

而不是使用通用解决方案:

cd $(brew --repository)
git reset --hard FETCH_HEAD

我必须做:

cd [directory of the file in question]
git reset --hard FETCH_HEAD

这解决了问题。

于 2013-07-25T21:56:53.780 回答
35

这为我修复了它:

https://stackoverflow.com/a/20138806

cd `brew --prefix`
git fetch origin
git reset --hard origin/master
于 2014-06-11T21:58:04.163 回答
2

在手动更正 numpy 公式中的 URL 后,我遇到了这个问题。我后来能够通过以下方式纠正这个问题:

cd /usr/local/Library/Taps/homebrew/homebrew-python
git checkout -- numpy.rb
brew update
于 2014-11-19T03:00:06.713 回答