Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 527
giuspen Avatar asked Jan 21 '12 12:01

giuspen


People also ask

How do I change my branch on Mercurial?

In the Status bar, click the Mercurial Branch widget to open the Branches popup. Select the branch or bookmark to which you want to switch and in the menu that opens, click Update.

What is Mercurial default branch?

Mercurial's main branch is called "default" and is analogous to "trunk" in SVN, "HEAD" in CVS, and "master" in Git.

How do I create a branch in Mercurial?

Branching can happen by committing a changeset within a single repository or by committing diverging changes in distinct (but related) repositories. Two repositories are said to be related if they were once cloned from the same repository but later may have diverged.


2 Answers

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.

like image 189
Martin Geisler Avatar answered Oct 11 '22 14:10

Martin Geisler


You could merge the branch into the default branch, like:

hg merge mybranchname
hg commit

Now the branch is in effect the main branch. You can hide the old branch with:

hg update mybranchname
hg commit --close-branch
like image 32
Andomar Avatar answered Oct 11 '22 15:10

Andomar