Git:如何将“合并远程跟踪分支”重新压缩和压缩到以后的提交?

时间:2019-05-10 08:36:25

标签: git

我创建了一个包含如下所示提交的请求请求。但是,我需要将将远程跟踪分支“原始/母版”合并为avsp 提交。

git日志输出

commit eb4b301a88f02adccecdc09b82e4fc4a12656d34 (HEAD -> avsp, origin/avsp)
Author: Nikhil P <nikhilap@blah.com>
Date:   Thu May 2 20:26:45 2019 -0700

    Address some review comments

commit 0ba34d2145688c133152e7db1d8bf29f503ab34c
Merge: 5e7c1a31 beacedb0
Author: Nikhil P <nikhilap@blah.com>
Date:   Thu May 2 00:32:02 2019 -0700

    Merge remote-tracking branch 'original/master' into avsp

commit beacedb0b2b2e4ceb1b8b626b94f66ba592356a4
Author: Guy Harris <guy@alum.mit.edu>
Date:   Wed May 1 00:23:08 2019 -0700

    Remove the IPv6 payload length checks for checksumming.

    If there isn't an IPv6 payload, there isn't any TCP or UDP packet, and
    there's no TCP or UDP header to checksum, so there's no need for the
    check (it's not there for IPv4).

预期的git log

commit eb4b301a88f02adccecdc09b82e4fc4a12656d34 (HEAD -> avsp, origin/avsp)
Author: Nikhil P <nikhilap@blah.com>
Date:   Thu May 2 20:26:45 2019 -0700

    Address some review comments

commit beacedb0b2b2e4ceb1b8b626b94f66ba592356a4
Author: Guy Harris <guy@alum.mit.edu>
Date:   Wed May 1 00:23:08 2019 -0700

    Remove the IPv6 payload length checks for checksumming.

    If there isn't an IPv6 payload, there isn't any TCP or UDP packet, and
    there's no TCP or UDP header to checksum, so there's no need for the
    check (it's not there for IPv4).

我试图将最后2次提交重新压缩并压缩为1,所以我尝试了

  

git rebase -i HEAD〜2

这导致大约450次提交

  1 pick 111e17e8 Don't use CMAKE_C_STANDARD, it doesn't work on all versions of CMake.
  2 pick 32f8eded Initialize C_ADDITIONAL_FLAGS where we start setting it.
   ** Snipped 400 more commits here ** 
451 pick beacedb0 Remove the IPv6 payload length checks for checksumming.
452 pick eb4b301a Address some review comments

现在,当尝试选择 eb4b301a 提交并压缩其余内容时,我在下面看到此错误:

error: cannot 'squash' without a previous commit
You can fix this with 'git rebase --edit-todo' and then run 'git rebase --continue'.
Or you can abort the rebase with 'git rebase --abort'.

如果无法重新设置基准,是否可以简单地从提交历史记录中删除提交?因此会有副作用吗?

1 个答案:

答案 0 :(得分:0)

1)要在交互式基准库中执行压扁操作,您需要具有被压扁的提交的父提交。原因是-被压榨的提交被压榨到父提交:)

因此,您不能压缩最后一个提交,因为它没有要压缩的提交。

就您而言,如果您放置

451 squash beacedb0 Remove the IPv6 payload length checks for checksumming.
452 pick eb4b301a Address some review comments

您将能够进行基准调整。

2)我想您只需执行交互式重新设置即可,无需执行任何特定操作即可摆脱合并提交。尝试这样做:

git rebase -i HEAD~2

由于合并提交,它将显示450多个提交,并显示一个列表以进行选择/压缩/删除。

请勿更改任何操作,并继续进行[ESC +:wq(对于Windows OS)]。 现在,一旦显示成功重新建立基准,请检查git log。

相关问题