自制程序更新失败:"请提交您的更改或存储它们,然后才能合并"

时间:2013-07-25 21:21:26

标签: macos git homebrew

我正在跑步:

brew update

我收到错误:

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

事实证明这是一个众所周知的错误。事实上,它在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

我按照这些说明操作,但仍然看到同样的错误。有什么问题?

3 个答案:

答案 0 :(得分:105)

我能够自己解决这个问题。

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

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

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

我必须这样做:

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

解决了这个问题。

答案 1 :(得分:35)

这为我解决了这个问题:

https://stackoverflow.com/a/20138806

cd `brew --prefix`
git fetch origin
git reset --hard origin/master

答案 2 :(得分:2)

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

cd /usr/local/Library/Taps/homebrew/homebrew-python
git checkout -- numpy.rb
brew update
相关问题