Why can't I push this change to my 'main' mercurial repository?

18,386

Solution 1

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.

Solution 2

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.

Solution 3

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.

Share:
18,386
Neil Trodden
Author by

Neil Trodden

Things that I'm working with these days: terraform kubernetes .Net Core Automate everything - infrastructure as code everywhere.

Updated on June 07, 2022

Comments

  • Neil Trodden
    Neil Trodden about 2 years

    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.

  • Neil Trodden
    Neil Trodden over 13 years
    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.
  • gcb
    gcb about 11 years
    isn't the best practice to merge the remote changes locally and then push?
  • irag10
    irag10 almost 11 years
    @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.