How to move some changeset to a new branch in mercurial

David Cournapeau picture David Cournapeau · Feb 8, 2010 · Viewed 22.3k times · Source

I want to move a changeset from one branch to another. Basically, I currently have:

A -> B -> C -> D # default branch

And I want:

A # default branch
 \-> B -> C -> D # some_new_branch

Where some_new_branch does not exist yet. I am used to git, so I guess there is a simple "mercurial" way I am missing.

Answer

Mark Tolonen picture Mark Tolonen · Mar 20, 2010

One way is to export a patch for B,C,D; update to A; branch; apply patch:

hg export -o patch B C D
hg update A
hg branch branchname
hg import patch

To remove B,C,D from the default branch, use the mq extension's strip command.