Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 442
max Avatar asked Jan 31 '12 19:01

max


People also ask

How can I delete last commit in Mercurial?

If you are still in the draft phase (not pushed elsewhere yet), use the built-in extension hg strip <rev> command. Otherwise, you should do a hg backout , which will reverse the changeset. In case you still need the commit you made, I suggest you export it to import it again in the correct branch, before stripping.

How do you merge Heads in Mercurial?

To start a merge between the two heads, we use the hg merge command. We resolve the contents of hello. c This updates the working directory so that it contains changes from both heads, which is reflected in both the output of hg parents and the contents of hello.


2 Answers

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.

like image 50
Martin Geisler Avatar answered Sep 19 '22 11:09

Martin Geisler


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 
like image 42
Alex from Jitbit Avatar answered Sep 18 '22 11:09

Alex from Jitbit