git:如何将几个提交重新组合成一个

时间:2018-01-02 18:51:24

标签: git rebase

这是我当前的日志,从最近的提交到最近的提交:

E   I want this message
D   I don't want this message
C   Don't want this message
B   Don't want this message
A   Want this commit separately

我想将提交B-E压缩到单个提交中,并保持提交A单独,以便它看起来像这样:

F   I want this message
A   Want this commit separately

其中F包含从BE的所有更改。我试过这个:

git rebase -i A

pick A Want this commit separately
reword B I want this message
fixup C
fixup D
fixup E

它提示我输入提交消息,自动填充提交B中的现有消息,然后失败,说You asked to amend the most recent commit, but doing so would make it empty.

如何获得我想要的历史记录?

1 个答案:

答案 0 :(得分:1)

来自another question

您可以:

git commit --allow-empty
git rebase --continue
git rebase -i HEAD~~
# fixup or remove second (empty) commit
相关问题