-->

Branching in Mercurial

2020-07-07 11:22发布

问题:

I have starting using Mercurial for my (our) versioning needs. I have now come to the point that I need to create a feature branch. However, now that I have started working on it -- and I try to push my changes, I keep getting a warning about new remote heads. That's stupid, I know that there will be new remote head(s) that's what a branch after all is?

How am I supposed to create branches and push them without this problem, without using force push as it is surely not the right way to go, right?

I thought about using separate repositories, but that feels just stupid especially for feature branches.

Any help welcome!

回答1:

To date, the best guide out there is Steve Losh's "A Guide to Branching in Mercurial".

Mercurial will always complain about creating new heads on the remote. You must use either --force or --new-branch when creating a new head.

When using TortoiseHg, the same can be accomplished via the Synchronize view of the Workbench. Click Options and then select the Allow push of a new branch or Force push or pull option, as needed.

The reason it behaves this is way is that the Mercurial developers wanted to make it a conscious decision to create a new head on the remote. Their view is that typical workflows should merge changes prior to pushing.



回答2:

This tutorial by Joel Spolsky helped me a bunch when I just started out with mercurial. It might be helpful for you as well:

http://hginit.com/