49

I am trying to grok Mercurial and hope I am just getting confused here!

I have a repository ('main') that I have cloned ('clone'), , both on my own machine. Both were completely in sync with each other.

I decided to play with named branches so the next time I committed on my 'clone' I did it under a branch name of 'case1212' and while it seems to have dealt with the commit properly on my clone, I cannot push these changes back to 'main'. The error given is:

abort: push creates new remote branch 'case1212'!

...and it suggests that I might need to merge first? What am I supposed to merge on that 'clone' repository? When I try to pull from 'main', there are no changes.

I'm pretty sure I actually would want it to create a remote branch in my 'main' repository so people who update from it can see that branch.

3 Answers 3

50

Mercurial's default behavior prevents you from creating remote branches. If you want to do this, you need to force-push.

Synchronize menu in the window you show, there is an option for force push.

2
  • isn't the best practice to merge the remote changes locally and then push?
    – gcb
    Apr 18, 2013 at 17:43
  • 4
    @gcb sometimes you genuinely want a new branch on the server repository so it's available for others to see & use. But if it's just a separate head because you haven't merged others' changes locally then yes, you should merge before push and then you don't need to force-push.
    – Rory
    Jul 5, 2013 at 18:25
24

Tortoise now has an option Push new branch that may be safer than Force pull or push. The command line tool has a flag --new-branch.

Update: The new tortoise interface makes it a bit harder to find. Switch to the Synchronise view, then click options and select allow push of a new branch.

1
  • 9
    It does and I make good use of it! I hate having force push left on permanently, just feels a bit like running linux as root all the time. Jan 18, 2011 at 13:44
19

It's warning you that your push would create new remote heads (and in this case branches). If you're okay with that, and it sounds like you are, you can push with push -f.

This check is in there so that if you wanted that case1212 branch to not go back to the main server you could do hg push -r default and then you'd not see this warning and not send case1212.

Once you've done this for case1212 you won't see the warning again since case1212 will already be there.

Newer versions of mercurial make that warning a little less scary sounding in the case where the new head is a new branch.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.