Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
Fix brew update local changes bug
Browse files Browse the repository at this point in the history
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
jacknagel authored and mxcl committed Aug 2, 2011
1 parent 9944836 commit cbcd4a3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/update.rb
Expand Up @@ -42,7 +42,7 @@ def update_from_masterbrew!
begin begin
safe_system "git init" safe_system "git init"
safe_system "git fetch #{REPOSITORY_URL}" safe_system "git fetch #{REPOSITORY_URL}"
safe_system "git reset FETCH_HEAD" safe_system "git reset --soft FETCH_HEAD"
rescue Exception rescue Exception
safe_system "rm -rf .git" safe_system "rm -rf .git"
raise raise
Expand Down

3 comments on commit cbcd4a3

@kerihenare
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worked like a charm, thanks!

Please sign in to comment.