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

问题描述 投票:0回答:1

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

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压缩到一个提交中,并保持提交一个单独的,所以它看起来像这样:

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

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

我怎样才能得到我想要的历史?

git rebase
1个回答
1
投票

来自another question

你或许可以:

git commit --allow-empty
git rebase --continue
git rebase -i HEAD~~
# fixup or remove second (empty) commit
© www.soinside.com 2019 - 2024. All rights reserved.