Check out a particular branch?
Ah. I was asking the wrong question.
I needed to know how to switch to a particular branch in Mercurial.
The terminology you've used here is check out
.
If you're coming from git, then this means you probably want to set the state of your working directory to whatever is in the particular named branch.
In SVN, you might call this switching. While the answer to this question may be the same, if you ask the same question using git terminology (as you did here), you might not find that answer, so this question is still useful in itself.
In Mercurial, it's called updating: You update
the contents of your working tree, like so:
hg update -c <your-named-branch>
The -c
isn't necessary, but if you're used to git warning you before anything is permanently overwritten, you'll find it more comfortable. Use -C
instead to wipe all local changes, or -m
to merge changes.
If you're trying to check out a branch that only exists on a remote repository, you might want to use this instead:
hg pull -u <your-named-branch>
Or else just pull
(without -u
) first so that the remote branch is brought into your local repository before you use update
.
If you prefer git parlance, you'll be pleased to know that checkout
and co
are both aliases for update
. You can also use -r to specify a revision. See the update help page for more detail.