随着git rebase --interactive <commit>你能够压制任意数量的提交连成一个单一的一个.
除非你想将提交压缩到初始提交中,否则这一切都很棒.这似乎是不可能的.
有没有办法实现它?
在一个相关的问题中,我设法提出了一种不同的方法来解决第一次提交的问题,这也就是说,它是第二次提交.
如果您有兴趣:git:如何插入提交作为第一个,转移所有其他?
这给出了压缩多个提交的一个很好的解释:
http://git-scm.com/book/en/Git-Branching-Rebasing
但它不适用于已被推送的提交.如何在我的本地和远程回购中压缩最近几次提交?
编辑:当我这样做时git rebase -i origin/master~4 master,保留第一个pick,将其他三个设置为squash,然后退出(通过emacs中的cx cc),我得到:
$ git rebase -i origin/master~4 master
# Not currently on any branch.
nothing to commit (working directory clean)
Could not apply 2f40e2c... Revert "issue 4427: bpf device permission change option added"
$ git rebase -i origin/master~4 master
Interactive rebase already started
Run Code Online (Sandbox Code Playgroud)
其中2f40是pick提交.现在,4个提交中没有一个出现git log.我希望我的编辑器能够重新启动,以便我可以输入提交消息.我究竟做错了什么?