Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit cbcd4a32a648d2dfc808066dc3200f92c1a2f020 1 parent 9944836
@jacknagel jacknagel authored mxcl committed
Showing with 1 addition and 1 deletion.
  1. +1 −1  Library/Homebrew/cmd/update.rb
View
2  Library/Homebrew/cmd/update.rb
@@ -42,7 +42,7 @@ def update_from_masterbrew!
begin
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"
raise

3 comments on commit cbcd4a3

@kerihenare

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:
Library/Formula/bulk_extractor.rb
Library/Formula/wine.rb
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
Owner

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.

@anthonybrown

worked like a charm, thanks!

Please sign in to comment.
Something went wrong with that request. Please try again.