如何在Git中合并分支后压缩提交?

时间:2015-12-17 15:31:13

标签: git github

我在 newFeature 分支中开发了一项新功能。在我将 newFeature 分支上的提交压缩之前,我已将分支合并到主分支。

我在分支上提交历史记录: enter image description here

我尝试过命令git rebase -i origin/master,与the example from this post相比,文件看起来有所不同。 根据帖子的回答,它应该类似于以下内容:

pick 16b5fcc Code in, tests not passing
pick c964dea Getting closer
pick 06cf8ee Something changed
pick 396b4a3 Tests pass
pick 9be7fdb Better comments
pick 7dba9cb All done

因为在VIM中,我看不到任何看起来像这样的东西,如图所示。
我是否必须在pick ...行和rebase ...行之间手动输入VIM中的Commonds:

enter image description here

如果git rebase对我不起作用,我还会阅读帖子Squash my last X commits together using Git。我想知道git reset --hardgit merge --squash命令是否可以解决我的问题。

当我执行git log时,我能够看到提交内容。

问题:

如何从第一次提交 aab9e06 压缩提交以提交 e8abbb0

1 个答案:

答案 0 :(得分:0)

几乎在那里,你只需要指定你想要用于rebase的提交。所以在你的情况下,它看起来像:

git rebase -i aab9e06
相关问题