Push creates new remote heads!

Monday, July 20th, 2009

Tags: mercurial, mercurial_error_message, version_control.

I'm putting this where I can easily find it again. I was working on the nyc-python website this afternoon. It's the first time I've used Mercurial for anything. I wish I could remember exactly how I backed myself into this particular corner, but I think it's that I added and committed changes before pulling from the repo. The other developer, Art, had in the meantime pushed other changes to the repo.

In any case, I tried to push to the repo and it told me:

pushing to ssh://[...] 
searching for changes 
abort: push creates new remote heads! 
(did you forget to merge? use push -f to force)

OK, no problem!

hg merge

Not no problem! The response:

abort: outstanding uncommitted changes

OK, I thought I had committed my changes, but whatever:

hg add
hg commit

But then Mercurial told me that I had no changes to commit.

I found the explanation and a solution here.

The explanation: "Apparently you had uncommited changes (check with hg st -m) and so the merge aborts (it could come out with conflicts on files that have to be merged and have uncommitted changes)."

The solution:

$ cd ..
$ hg clone nycpython nycpython-merge
$ cd nycpython-merge/
$ hg merge
$ hg ci
$ cd ..
$ cd nycpython
$ hg pull ../nycpython-merge 
$ hg update
$ hg pull
$ hg push

And it worked!