将最近的提交放在Mercurial(Hg)的单独(命名)分支中

Iga*_*nik 4 mercurial branch tortoisehg

如果自上次推送以来我对默认分支进行了多次提交,是否可以返回,并将这些提交移动到单独的命名分支中?

也就是说,我有:

A--B--C--D
Run Code Online (Sandbox Code Playgroud)

而且我要:

A
 \
  B--C--D
Run Code Online (Sandbox Code Playgroud)

我希望这是有道理的?

jwd*_*jwd 5

看看Transplant扩展.

但就个人而言,我会使用MQ来做,就像这样:

# assuming revs 1 and 2 are the ones we want to move
hg qimport -r1:2

# qimport creates a patch for each changeset
>hg qapplied
1.diff
2.diff

# pop the patches, to save for later
>hg qpop -a
popping 2.diff
popping 1.diff
patch queue now empty

# switch branches
>hg branch my-branch
marked working directory as branch my-branch

# push our saved changesets, essentially rebasing on the new branch
>hg qpush -a
applying 1.diff
applying 2.diff
now at: 2.diff

# make the patches part of permanent history
>hg qfin -a
Run Code Online (Sandbox Code Playgroud)

如果您愿意,也可以弯曲Rebase扩展以适应此目的.