代码之家  ›  专栏  ›  技术社区  ›  aidan

cherry-pick-merge-commit失败,提交为空

  •  3
  • aidan  · 技术社区  · 7 年前

    我有几个分支,我希望第二个分支的更改出现在第一个分支中。

    最好用图表来描述:

              X - Y - Z    (branch-2)
             /         \
    A - B - C - D - E - F  (master)
     \     
      G - H - I            (branch-1)
    

    我想合并 X ,请 Y ,请 Z 进入之内 branch-1 不带 B C .

    我试着选择合并提交 F 尽管我指定了正确的父对象(我认为),但cherry pick失败的原因是: The previous cherry-pick is now empty, possibly due to conflict resolution.

    我要樱桃色的吗 X^..Z 范围?还是有更好的方法?

    1 回复  |  直到 7 年前
        1
  •  4
  •   Timothy Truckle Vincent Boutot    7 年前

    如果那样的话,一个接一个地选择樱桃可能是个解决办法。 branch-2 很小。

    要移动更大的分支,我会这样做:

    git checkout branch-2
    git branch   moving/branch-2 # new branch to work with
    git rebase --onto  branch-1 [sha_of_c] moving/branch-2 # move commits of branch ontop of the other 
    git checkout branch-1 
    git reset --hard  moving/branch-2 # set branch lable to new HEAD
    git branch -d  moving/branch-2 # clean up
    

    按照建议 @奎泽尔卡特 在评论中,您可以使用 -i 与…交换 rebase 因此,您可以在实际执行之前检查是否复制了正确的提交。

    另一方面,如果出了问题,你可以简单地恢复 moving/branch-2 分支机构2 重新开始。