Create a new branch at a certain revision
36,390
Solution 1
Preface: Mercurial branches are two types:
- named branch
- anonymous
Named Branch
In order to get named branch BRANCHNAME, starting at REV
hg update REV
hg branch BRANCHNAME
...
hg commit
commit is a must, because
the branch will not exist in the repository until the next commit
as noted in hg help branch
Anonymous branch
hg update REV
...
hg commit
and current branch get additional head
And as a last step, use the following command to create a remote branch and push the changesets.
hg push --new-branch
Solution 2
You could you hg clone -r <rev>
. From the command line help (run hg -v help clone
):
- create a repository without changesets after a particular revision:
hg clone -r 04e544 experimental/ good/
Author by
Mot
Updated on July 13, 2020Comments
-
Mot almost 4 years
With mercurial it is easy to create a tag at a certain revision:
hg tag -r <revision> <tag-name>
. But how to create a branch at a certain revision? -
Lazy Badger over 11 yearsClone isn't branch per se. It will (may) appear only after hg pull|push from|to SRC repo
-
Serge Belov over 11 years@LazyBadger My bad, thanks for pointing that out. +1 to your answer.
-
Francois almost 8 yearsproblem: when doing
hg update 679; hg branch mybranch; hg commit
, the branch mybranch will still start at the tip of branch default, not at revision 679. -
Lazy Badger almost 8 years@Francois - check current rev after update with
hg id -n