【问题标题】:Homebrew update fail: "Please, commit your changes or stash them before you can merge"Homebrew 更新失败:“请在合并之前提交您的更改或存储它们”
【发布时间】:2013-07-25 21:21:25
【问题描述】:

我正在跑步:

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

我按照这些说明操作,但仍然看到同样的错误。怎么了?

【问题讨论】:

    标签: macos git homebrew


    【解决方案1】:

    我自己解决了这个问题。

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

    而不是使用常见的解决方案:

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

    我必须这样做:

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

    这解决了问题。

    【讨论】:

    • 谢谢!它修复了我的一个 git 冲突。 git reset --hard FETCH_HEAD 到底是什么?
    • bash cd $(brew --repository) git reset --hard FETCH_HEAD 大部分时间都为我工作 :)
    【解决方案2】:

    这为我解决了问题:

    https://stackoverflow.com/a/20138806

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

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

        猜你喜欢
        • 2019-07-11
        • 2018-04-24
        • 2020-12-09
        • 2021-02-25
        • 2019-11-08
        • 2019-11-05
        • 1970-01-01
        相关资源
        最近更新 更多