【发布时间】:2021-04-30 12:46:58
【问题描述】:
我有一个 git 这样的历史记录:
* aab941c (HEAD -> master) Added ...
| * 2519b79 (participantQueue) Added ...
| * 39c4efb Created ...
|/
* 87b0cf7 Import ...
| * 5569822 (settings) Modified ...
|/
* ee67831 Added ...
* c07902f Added ...
* 7f5ab04 Added ...
* 82be721 Modified from `A` to `B`
* d86702b Modified from `A` to `B`
* 8cad721 Modified from `A` to `B`
* 5db240b Removing ...
我想将8cad721 压缩为82be721,最终得到:
* aab941c (HEAD -> master) Added ...
| * 2519b79 (participantQueue) Added ...
| * 39c4efb Created ...
|/
* 87b0cf7 Import ...
| * 5569822 (settings) Modified ...
|/
* ee67831 Added ...
* c07902f Added ...
* 7f5ab04 Added ...
* 82be721 Modified from `A` to `B` (82be721, d86702b squashed into here)
* 5db240b Removing ...
我已经尝试过git rebase -i 5db240bas suggested in other SO answers,将pick 替换为squash 用于d86702b 和82be721。结果如下:
* 4d91ea0 (HEAD -> master) Added ...
* 7040d3c Import ...
* f6c0fb5 Added ...
* 299c918 Added ...
* 58b209f Added ...
* e8b36f7 Modified from `A` to `B`
| * 2519b79 (participantQueue) Added default participant properties to unpaired queue export
| * 39c4efb Created ...
| * 87b0cf7 Import ...
| | * 5569822 (settings) Modified ...
| |/
| * ee67831 Added ...
| * c07902f Added ...
| * 7f5ab04 Added ...
| * 82be721 Modified from `A` to `B`
| * d86702b Modified from `A` to `B`
| * 8cad721 Modified from `A` to `B`
|/
* 5db240b Removing ...
我应该改用什么命令?
在 LeGEC 实施以下答案后,我有以下几点:
* 669164c (participantQueue) Added ...
* 5bc13a8 Created ...
| * 6abf940 (settings) Modified ...
| | * 3518be1 (HEAD -> master) Added ...
| |/
|/|
* | 2692632 Import ...
|/
* 810389b Added ...
* 0c85217 Added ...
* 9284cff Added ...
* eee5eef Modified from `A` to `B`
* 5db240b Removing ...
这让我愣了一秒,因为它看起来确实不同,但对master 的再次提交会像以前一样重新排序git log 输出的“主干”。
【问题讨论】: