【问题标题】:Placing recent commits in a separate (named) branch in Mercurial (Hg)将最近的提交放在 Mercurial (Hg) 中的单独(命名)分支中
【发布时间】:2011-05-04 20:57:49
【问题描述】:

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

也就是说,我有:

A--B--C--D

我想要:

A
 \
  B--C--D

我希望这是有道理的?

【问题讨论】:

    标签: mercurial branch tortoisehg


    【解决方案1】:

    看看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
    

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

    【讨论】:

      【解决方案2】:

      如果提交仍然仅在您的本地存储库中并且没有被推送到任何其他存储库,那么是的,您可以以相当小的麻烦重新安排它们。但是,如果他们已经超越了您的本地仓库,那么您将遇到很多麻烦。

      要重新安排提交,您需要使用 MQ 扩展名。 Here's a tutorial,因为它比我在这里解释的更好。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-05-04
        • 1970-01-01
        • 2011-01-22
        • 1970-01-01
        相关资源
        最近更新 更多