Search code examples
mercurial

Mercurial - how to get rid of additional default heads


I am on the default branch, but some old commits are said by mercurial to be other default heads. I would like to push a commit, but I can't because otherwise I would have to push other default heads which would be wrong.

How can I make the situation clean? I assume I have to get reed of these additional default heads and so that I again push my work. Is there a safe way to do it?


Solution

  • First piece of advice is to backup you repo so that if something goes wrong, you have a return path.

    You will need to determine if the other heads are important or if they can be thrown away. You can list the heads with:

    hg heads
    

    if the other heads are throwaways, you can use the hg strip command. Some caution is needed here. If you created a anonymous branch (the head in question) and later merged it back to your default (or other branch), deleting it will cause any changed after the merge to also be removed.

    You should spend some time reviewing: hg log -G (or one of the many graphical interfaces) and determine if this is going to be an issue.

    If it is an orphan branch (head) you can use:

    hg strip changeset-id