"push creates new remote head" issue

Itamar Katz picture Itamar Katz · Aug 2, 2014 · Viewed 15.9k times · Source

I read all SO questions about this issue, and I still can't resolve it.

I am using TortoiseHg. I worked on a side-branch, and now I want to merge it back to the main branch. I pulled all changes made in both branches, updated to the main branch, and merged (and committed). But still when I try to push all this, I get the "abort:push creates new remote head" message.

I also tried (as was suggested in one of the questions in SO) to close the branch using the --close-branch option.

The only thing I did not try is to 'force' push. Any suggestions? Or is force-pushing the only option?

See screenshot

Answer

gijswijs picture gijswijs · Mar 30, 2015

Just for everyone else that runs into this problem. What caused this problem for me were some local revisions on the default branch that I didn't push before I started to work on a new branch.

I had merged the latest revision I pulled for the default branch with my new branch, but these leaves your local changes to the default branch committed but un-pushed.

If you try to push them, it's not your new branch that is creating a remote head, it's the un-pushed revisions to the default branch that is creating a remote head.

When I stripped out those revision with hg strip -r 1234

hg push --new-branch 

went perfect.

What put me on the right track was

hg heads

With showed I had two heads that both had the name of the default branch with different revision numbers.