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

brew update result in git merge message in editor #13987

Closed
tonymcdaniel opened this issue Aug 5, 2012 · 8 comments
Closed

brew update result in git merge message in editor #13987

tonymcdaniel opened this issue Aug 5, 2012 · 8 comments

Comments

@tonymcdaniel
Copy link
Contributor

A while back I cloned homebrew in order to add a new formula. Since then, whenever I do a brew upgrade, I get a new git merge window in MacVim (my default editor) with the contents "Merge branch 'master' of https://github.com/mxcl/homebrew".After saving the buffer, the update proceeds as usual.

Checking git status in the homebrew directory (/usr/local/) gives:
# On branch master
nothing to commit (working directory clean)

brew doctor gives no errors. This is an annoying problem, and I haven't been able to find any solutions by searching.

@2bits
Copy link
Contributor

2bits commented Aug 5, 2012

This is normal if you've made any changes in /usr/local/Library. When that message appears in your editor, use Shift+ZZ to save and exit. Your update will proceed normally with the only new thing being the commit message you accepted and saved, viewable using brew log --oneline.

On Lion with the system git, this message didn't appear. It's a new git feature, and it can be turned off with an environment variable (I forget which).

@tonymcdaniel
Copy link
Contributor Author

I'm using the homebrew version of git:
$ git --version
git version 1.7.11.3

$ which git
/usr/local/bin/git

The only change I made to /usr/local/Library was adding the new formula. Once it was merged into homebrew, I switched back to the main repository (instead of my clone).

Searching the git docs, I found what I think is the correct environment variable. export GIT_MERGE_AUTOEDIT='no'. I've set this but will have to wait until the next update to test.

@mxcl
Copy link
Contributor

mxcl commented Aug 6, 2012

Not a Homebrew bug. if it wants you to merge everytime then you are merging everytime, I suggest you hard reset.

@mxcl mxcl closed this as completed Aug 6, 2012
@tonymcdaniel
Copy link
Contributor Author

I did git reset --hard in /usr/local/ but I still have MacVim asking for a merge message every time I brew update.

Is there anything else I should try?

@mxcl
Copy link
Contributor

mxcl commented Aug 6, 2012

I imagine you hard reset to your fork rather than to mine. Try again.

@timgilbert
Copy link

In case anyone else is experiencing this same issue, I was seeing the same behavior and was able to fix it by issuing "git reset --hard origin/master" in /usr/local.

@whitehat101
Copy link

I ram upon a similar issue, and I've been ignoring it for a while. (I just fixed it.) I didn't (consciously) edit any files. I'm pretty sure the changes were caused through normal use of the brew command; but I don't really know or care. I agree Not a Homebrew bug. However, the user experience could be enhanced.

the error:

$ brew update
error: Your local changes to the following files would be overwritten by merge:
    Library/Contributions/cmds/brew-pull.rb
    Library/Contributions/cmds/brew-services.rb
    Library/Contributions/cmds/brew-test-bot.rb
    Library/Contributions/manpages/brew.1.md
    Library/ENV/4.3/make
Please, commit your changes or stash them before you can merge.
error: The following untracked working tree files would be overwritten by merge:
    Library/Aliases/ag
    Library/Aliases/qt4

All it said was 'Library'. Does it mean: ~/Library/, /Library/, /System/Library/? I had no idea, and of corse the answer was none of the above. Having a hint to where the issue was would have been helpful.

To help my coworkers who are new to git, I've pasted the following commands:

# git-omega-13
git stash save broken && git branch -M master broken && git checkout master
# git-omega-13-kill
git reset --hard && git branch -M master broken && git checkout master && git branch -D broken

It's a last resort, "I have no idea what's going on. Just make it work again!" It has saved a few soles from rm -f and git cloning a repo. Is there any harm in adding a brew update force that branches, stashes, or just discards anything that a non-brew hacker doesn't care about?

If they know what they've done, they can fix it. If they don't care, they just don't care.

@mariussoutier
Copy link
Contributor

git reset --hard origin/master did the trick for me, thanks @timgilbert!

@Homebrew Homebrew locked and limited conversation to collaborators Sep 14, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants