This repository has been archived by the owner. It is now read-only.
Browse files

Fix `brew update` local changes bug

Users were seeing local changes in their repository after updating, even
though they had made no local changes.

The repository setup sequence should use `git reset --soft` rather than
vanilla `git reset`, which defaults to '--mixed'. '--soft' updates
_only_ HEAD, leaving the index as-is, allowing future incantations of
`brew update` to proceed without errors.

Fixes #6732.
  • Loading branch information...
1 parent 9944836 commit cbcd4a32a648d2dfc808066dc3200f92c1a2f020 @jacknagel jacknagel committed with mxcl Jul 31, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 Library/Homebrew/cmd/update.rb
@@ -42,7 +42,7 @@ def update_from_masterbrew!
safe_system "git init"
safe_system "git fetch #{REPOSITORY_URL}"
- safe_system "git reset FETCH_HEAD"
+ safe_system "git reset --soft FETCH_HEAD"
rescue Exception
safe_system "rm -rf .git"

3 comments on commit cbcd4a3

I do a "brew update && brew upgrade" about once a week. Recently it's started throwing errors such as:

error: Your local changes to the following files would be overwritten by merge:
Please, commit your changes or stash them before you can merge.

The formulas aren't consistent (e.g.: different formulas each time) and I haven't made any local edits. If I update again within a short time frame the issue doesn't re-occur.


jacknagel replied Aug 3, 2011

You need to git reset --hard FETCH_HEAD inside your Homebrew installation. This fix isn't retroactive, i.e. it doesn't help people whose installation was already broken by the original bug. But after you run the aformentioned, it should be smooth sailing from then on.

worked like a charm, thanks!

Please sign in to comment.