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?
-
Maybe a duplication of http://stackoverflow.com/questions/5424377/make-another-branch-default – phemios Jan 21 '12 at 12:24
-
you're right, the question at the link above is the same of mine. I'm sorry I searched in google but didn't find it. – giuspen Jan 21 '12 at 13:25
3 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.

- 72,968
- 25
- 171
- 229
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

- 232,371
- 49
- 380
- 404
-
so the only way is to merge from the default branch, I cannot leave many branches and set a custom branch as the new default branch? – giuspen Jan 21 '12 at 13:20
-
Hmm, you can `clone -b mybranchname http://repo.url localdir` to start with "mybranchname" checked out. I don't think there's a way to make "tip" point to another branch, since "tip" is a real branch itself. – Andomar Jan 21 '12 at 14:26
-
1
-
my target is that a user clones all the repos without parameters, and in all repos after cloning he targets the version I want (latest in a branch). I can see the only way to obtain this result is through merge from not default branches to the default branch. thanks for the clarification. – giuspen Jan 21 '12 at 20:35
By default default branch is not "default", but branch from tip.
Just commit before clone-pull to any existing branch.

- 94,711
- 9
- 78
- 110
-
3
-
You always commit to the **branch of tip changeset** (if not up before commit to another branch), not to "default" branch – Lazy Badger Jan 21 '12 at 15:48
-
I already committed hundreds of times on a branch that I would like to become the default branch. I understand this is possible only through a merge to the default branch – giuspen Jan 21 '12 at 20:31
-
I can't see how this answer relates to the question, nor what it means. – Andreas Covidiot Jan 22 '19 at 14:34