Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a new branch at a certain revision

Tags:

mercurial

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?

like image 326
Mot Avatar asked Nov 25 '12 09:11

Mot


People also ask

How do you create a new branch in git from a specific commit?

In order to create a Git branch from a commit, use the “git checkout” command with the “-b” option and specify the branch name as well as the commit to create your branch from. Alternatively, you can use the “git branch” command with the branch name and the commit SHA for the new branch.

How do I create a new branch with an existing change?

The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch . Once created you can then use git checkout new_branch to switch to that branch.


1 Answers

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 
like image 88
Lazy Badger Avatar answered Sep 26 '22 01:09

Lazy Badger