Branching in Mercurial

April 3, 2010

There is a good article A Guide to Branching in Mercurial.

Basically, it says that there are a few ways to do branching, so just choose one and work with it. I chose Branching with Named Branches and it was really quite simple to make a simple branch and merge it with the default tip.

Basically just call hg branch myFeature and you mark your local working copy as being a branch with a name “myFeature”. If someone clones your copy (you should try cloning your copy in your local file system), the it will default to default tip, not to your branch.

After some development time, you must synchronize both branches. You do this simply with hg pull or hg push command. It’s just a matter of whether you want to push your changes to other repo, or get others changes from another branch.

When you update your local copy, it is interesting to start TortoiseHG repository explorer and see that there are two separate development trees. To merge those, you have to call hg merge -r revNR .  RevNR is the other branches tip revision number.

Note that while working this way, you wont get “branch <yourBranch> has two heads”.  AFAIK, this might happen if two separate developers would commit into the same branch, and then would try to merge.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: