如果自上次推送以来我对默认分支进行了多次提交,是否可以返回并将这些提交移动到单独的命名分支中?
也就是说,我有:
A--B--C--D
我想要:
A
\
B--C--D
我希望这是有道理的?
看看移植扩展。
但就我个人而言,我会使用 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
如果您愿意,您也可以弯曲 Rebase 扩展来满足此目的。