Search code examples
mercurialbranchclone

mercurial set a branch as the new default branch


The result I would need is that when cloning a repository the code is at the last revision of a branch that is not the default branch, with no need to do "hg update mybranchname". Is this possible?


Solution

  • The advice until now has been: you should always use default as your main branch since Mercurial will checkout default if it finds it in the repository.

    This changes a little with Mercurial 2.1: you can now close the default branch (if you have one) and add a bookmark named default in its place. A new clone will retrieve the bookmark and update to it, effectively switching to another branch in the process.

    Note that it's your responsibility to keep the default bookmark pointing to the head of the branch you want to checkout, so this is not 100% fool proof.