brew update result in git merge message in editor #13987

tonymcdaniel opened this Issue Aug 5, 2012 · 8 comments


None yet
6 participants

tonymcdaniel commented Aug 5, 2012

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".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 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 commented Aug 5, 2012

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

$ which 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 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 closed this Aug 6, 2012


tonymcdaniel commented Aug 6, 2012

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 commented Aug 6, 2012

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

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.

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:
Please, commit your changes or stash them before you can merge.
error: The following untracked working tree files would be overwritten by merge:

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 commented Sep 14, 2014

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

mistydemeo 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.