删除合并提交

时间:2012-07-12 21:51:48

标签: git

基本上,我要做的就是摆脱提交5581ecb023a9,它是在两个分支的合并过程中创建的。我想要的是一切都在一条直线上。

到目前为止,我曾尝试按照以前的帖子进行git rebase -i 5581ecb023a9,但它没有显示实际的5581ecb023a9提交。我试过git rebase -i a19ba5850a20,但也没有显示5581ecb023a9提交。

有关如何将它们全部排成一行的任何想法吗?

提前致谢。

2 个答案:

答案 0 :(得分:0)

您可以在一行逻辑中获取提交,但这样做重写历史记录

这意味着提交将具有不同的ID(SHA1校验和),因为git中的每个修订都包含其在校验和中的父ID。这使得git在cyrptographically安全(很容易验证从任何快照到根提交的整个存储库的完整性)。

要比较包含相同“逻辑”提交的分支,但重新定位或樱桃挑选到另一个分支,请执行此操作。

log --left-right --graph --oneline --cherry-pick BRANCH1 BRANCH2

正如git rev-list(以及其他)的联机帮助页解释的那样,--cherry-pick导致

  

- 樱桃挑选

    Omit any commit that introduces the same change as another commit on
    the "other side" when the set of commits are limited with symmetric
    difference.

    For example, if you have two branches, A and B, a usual way to list all
    commits on only one side of them is with --left-right (see the example
    below in the description of the --left-right option). It however shows
    the commits that were cherry-picked from the other branch (for example,
    "3rd on b" may be cherry-picked from branch A).

    With this option, such pairs of commits are excluded from the output.

答案 1 :(得分:0)

要做到这一点,你需要在之前对来自的提交进行重新定义,以便在合并的任何一方偏离其共同的祖先 - 例如git rebse 8fedb6