Mercurial clone from a branch

We have a repository with three named branches, I wanted to clone one of the branches. Is there a mercurial command to do that? If I provide the path (of branch) with hg clone I get 404 error.

  • Why am I able to create the same SVN branch twice?
  • git branch | grep '^SomeThingInFrontOfLine' not working
  • Recreate Git Ref after Fatal Error
  • How can I delete all local branches which would result in no changes if merged into master?
  • Show all branches that commit A is on and commit B is not on?
  • Merge two git repositories into one, keeping (renamed) master branches
  • Merge branch that was created with the same name as deleted one
  • merge-base analog for Mercurial and bzr (to find common ancestors as possible for a merge)?
  • What does this do: git branch -f
  • Can I nest subrepos in Mercurial?
  • Reordering of commits
  • Mercurial convert extension not able to pull from remote Git repository
  • 5 Solutions collect form web for “Mercurial clone from a branch”

    hg clone http://your/repo -r branchname should do the trick.

    Benjamin’s right. But is that really what you want to do? In particular, you’ll only get the changesets needed to make up that branch, and nothing else – and that would, for example, prevent you from pulling changesets in from the trunk or other branches. You might well be better off just cloning the entire repository and then simply working in the branch you are interested in; this will let you keep your repository in sync with the one you’re pulling from more easily.

    hg clone <URL> -b BRANCHNAME clone single branch, as requested

    I know that this post is very old, but I had the same question. I found this trick:

    hg clone /path/to/your/repo -r 0
    hg pull -u -b branchname
    

    I’m using Mercurial-4.0.2. In that we can specify the branch name by appending branch name with a # symbol in the clone url.

    e.g.

    hg clone https://user@cloneurl/my_product#MY_BRANCH
    
    hg clone --verbose https://user@cloneurl/my_product#MY_BRANCH "C:\myCode"
    
    Git Baby is a git and github fan, let's start git clone.