自制软件更新失败:“请提交您的更改或存储它们,然后才能合并”

我在跑步:

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 

我遵循这些指示,仍然看到相同的错误。 哪里不对?

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

什么给我的是运行“git状态”没有显示该文件。

而不是使用常见的解决scheme:

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

我必须做:

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

这解决了这个问题。

这对我来说是固定的:

https://stackoverflow.com/a/20138806

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

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

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