macos - Homebrew 软件更新失败 : "Please, commit your changes or stash them before you can merge"

标签 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

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

最佳答案

我能够自己解决问题。

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

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

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

我必须做的:

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

这解决了问题。

关于macos - Homebrew 软件更新失败 : "Please, commit your changes or stash them before you can merge",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17868956/

相关文章:

macos - Hammerspoon - 如何粘贴文本?

linux - 当我在 shell 脚本中运行但在终端控制台中成功运行时抛出错误

android - 如何将 bitbucket 私有(private) Git 存储库添加到 AOSP?

linux - 非登录用户的 .ssh/authorized_keys 文件在哪里?

scala - 在 IntelliJ 中,我在哪里输入 Homebrew Scala 路径/usr/local/opt/scala/idea?

python - 让 Fabric Python 库工作

python - Homebrew 将 python 链接到/usr/local/bin/on Mac

c - 如何在 SQLite 中编译用户定义的函数

git - 我需要手动获取 ~/.bashrc 以在我的命令提示符中显示和更新 GIT 分支

java - 如何创建 AppleScript 或命令文件以在 Mac OS 上启动 Java 应用程序?