This page provides three different ways to get rid of branches, but it will also work for heads. Branch is created when changeset has more than one child. Named branches can be created using the hg branch command, however unnamed branches can be created (either by mistake or by designation) by making two sets of changes for the same parent.
For example, if I create a new repository, add a file to it and commit that commit will changeet 0.
hg init
Then I make a few more changes and commit them again, creating changeet 1 whose parent is change set 0.
# more edits to myfile.txt hg ci -m 'changed myfile.txt'
Now for some unknown reason, I go back to change set 0, make some changes to myfile.txt, and commit them.
hg up -C 0
Now we have done something strange. We returned to change list 1 and made various changes. We returned on time to our code and changed something by creating an alternative universe, as in BttF Part II!
Well, not really. We really created a branch. However, this is an unnamed branch, since we did not create it using the hg branch command (and therefore do not appear in hg branches). He also created a new head . Heads are simply changes without children, so any branch, named or unnamed, that has not been merged or closed, will have a head.
This is a contrived example and may not be what you did. What is more common if you work in two places and forget to press when you do it in one place, or pull when you start work in another place again. If you donβt click when this is done in one place, when you start work in 2nd place, you can work on an older set of changes, and thus, any commits will create a second head. This happens when you forget to pull.
As I said earlier, this creates an unnamed branch. However, you can view this branch just like any other branch. The hg update branch_name simply updates you to the title of this branch, so for an unnamed branch, you can simply update the head of this unnamed branch with hg update head_revision and hg heads to display the heads for you (or hg heads -v if you need more information about each head).
I would recommend just closing your head that you no longer want (the first option is on the first link above). So it still exists just in case you need it later, but it does not appear in hg heads . To do this, run the following commands:
hg up -C head_to_close hg commit --close-branch -m 'Closing un-wanted head' hg up -C head_to_keep
You will need to figure out which head you want to close. hg heads -v will provide you with additional head information. You can also upgrade to each hg up head_changeset and examine the code to find out which one you want to close.