Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We've got a repository with two named branches in it: dev and production. There's also the default branch, which we aren't using. Unfortunately, whenever people clone the repository, it automatically puts them on default, and we're having problems because people will inadvertently commit to it.

Is there a way to delete the default branch, or disable it, or set Mercurial so that clones will automatically start on the dev branch?

share|improve this question
up vote 3 down vote accepted

The mercurial documentation has some examples of precommit hooks and one, ironically, is checking the branch name. In the example, it checks to make sure it matches a regular expression. You could tweak it to make sure the name isn't "default".

This may not prevent the clones from starting on the "default" branch, but at least with this hook in place, no one can put any code into "default".

share|improve this answer

This answer has become outdated: you can now add a @ bookmark and Mercurial 2.4 and later will automatically check it out for a new clone. Your users will have to be careful about keeping the @ bookmark pointed at the branch head they want, though.

You cannot make another branch the default branch, by which I mean you cannot tell Mercurial that you would like branch-X to be checked out in a new clone. You should always make default the branch the branch that users want to checkout. This is described in the wiki.

People sometimes try to delete the default branch. This can be done by not creating one in the first place:

$ hg init repo
$ cd repo
$ hg branch dev
$ hg commit -m "Ha, no default branch!"

When there is no default branch present, hg clone will checkout the tip-most changeset. This is a bad idea since this changeset changes every time something is pushed to the repository. So if you have a dev and prod branch in the repo, then a new clone will checkout a "random" changeset depending on where the last commit was made. That is even more confusing that teaching people that default means "the normal branch where you should work by default".

share|improve this answer
Badly I have don't your "bad idea" (I was young). It's a way to repair it? I have made a question… with my problem. – PhoneixS Jul 3 '14 at 16:34

Is there any reason you couldn't just do your development in Default, and when it's released to production, you then branch it to Production?

UPDATE: given your request, have you tried using Named Branches explicitly in your commands?

share|improve this answer
We prefer to have our development done on a specific name (i.e., "dev") because it's explicit. – Chris B. Oct 12 '10 at 14:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.