Homebrew 更新错误,本地更改将被覆盖

Homebrew 更新错误,本地更改将被覆盖

我对 homebrew 和 git 还很陌生。

httpd24.rb我已经对 tap中的公式进行了更改homebrew/apache。(只需--enable-so在现有公式文件中添加配置参数)

现在当我尝试时brew update我得到了这个:

$ brew update
error: Your local changes to the following files would be overwritten by merge:
    httpd24.rb
Please, commit your changes or stash them before you can merge.
Aborting
Error: Failed to update tap: homebrew/apache
Already up-to-date.

还得到了这个:

$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    Library/Formula/httpd24.rb

nothing added to commit but untracked files present (use "git add" to track)

我如何保存对配方的更改并能够保持自制更新?

答案1

请提交您的更改或将其存储起来,然后才能合并。

提交你的更改git add Library/Formula/httpd24.rb && git commit -m "This is your commit message"

当你运行时,brew update它的工作类似于git pull命令。如果您有未提交的更改,则无法更新本地存储库。

答案2

尝试这个:

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

来源:Homebrew 的常见问题

答案3

要修复 Homebrew 问题,请运行以下命令:

git --git-dir $(brew --repository)/.git reset origin/master --hard
git --git-dir $(brew --repository)/.git clean -fd

对于 Git 问题,请参阅:

相关内容