web-dev-qa-db-ja.com

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

私はそれらの指示に従いましたが、まだ同じエラーが表示されています。なにが問題ですか?

65
burger

私は自分で問題を解決することができました。

「git status」を実行すると、そのファイルは表示されませんでした。

一般的なソリューションを使用する代わりに:

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

私がしなければなりませんでした:

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

これで問題は解決しました。

105
burger

これは私のためにそれを修正しました:

https://stackoverflow.com/a/20138806

cd `brew --prefix`
git fetch Origin
git reset --hard Origin/master
35
javabrain

Numpy式のURLを手動で修正した後、この問題が発生しました。私はこれを後で修正することができました:

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