creating a new branch in mercurial: "abort: push creates new remote head"

25,793

Solution 1

You tell Mercurial that it can go ahead with

$ hg push --force

You need to force it since multiple (unnamed) heads are normally discouraged. The problem with them is that people that clone the repository wont know which one to use. But since you're the only user you can just go ahead and push.

The alternative is to use a named branch (with hg branch) and then you'll use

$ hg push --new-branch

to allow the creation of a new branch on the remote. Named branches have the advantage that they make it easy to distinguish the two branches. They have the disadvantage that they are permanent. Permanent means that you cannot remove the branch name from the changesets on the branch — the name is literally baked directly into the changeset.

Bookmarks provide a way to have non-permanent branch names, see hg help bookmarks.

Solution 2

Another reason for this error: probably there are some UNMERGED changes form the central repo in your default branch.

hg up default
hg merge
hg ci -m "Merge"
hg pus
Share:
25,793
max
Author by

max

Updated on February 23, 2020

Comments

  • max
    max over 4 years

    I am trying to do something very simple: create a new branch. But I messed up. Where did I make the mistake, and how do I fix it?

    I am the only user of Mercurial. I had revision 54 committed and pushed to remote repository. I wanted to create a branch based on revision 53, so I updated my local copy to revision 53, made changes, and committed (ignoring the warning about "it's not the head"). Then when I am trying to push to remote repository, it says

    abort: push creates new remote head
    

    Maybe I needed to tell Mercurial that I want to create a new branch? If so, how and at what point?

    Thanks!