0

考虑以下本地分支上的一系列提交:

5 Correction of something meaningless, again !
4 Business correction n°3
3 Correction of something meaningless
2 Business correction n°2
1 Business correction n°1

我想用 3 压缩 5 以获得:

4 Correction of something meaningless, squashed !
3 Business correction n°3
2 Business correction n°2
1 Business correction n°1

我可以使用交互式变基来做到这一点吗?从我所看到的(例如:https ://www.internalpointers.com/post/squash-commits-into-one-git )和迄今为止的测试来看,我只能通过一系列直接提交来压缩 5,例如:

  • 4
  • 4 3
  • 4 3 2
  • 4 3 2 1
4

1 回答 1

2

您可以使用交互式变基来做到这一点。

只需在 git 提示时重新排序这样的行:

squash 5 Correction of something meaningless, again !
pick 3 Correction of something meaningless
pick 4 Business correction n°3
pick 2 Business correction n°2
pick 1 Business correction n°1

但是,因为你改变了顺序,可能会发生冲突,有时这不值得重写历史......

于 2019-09-19T14:50:08.080 回答