如何合并两个不间断的提交

时间:2014-04-17 09:28:25

标签: git squash git-squash

我想合并e5c1e1d627c6c6

怎么做?我想要一种更简单的方法。

因为如果它们之间有数百次提交,那么执行回滚然后重新提交会很麻烦。

screenshot

* fc60bec - (HEAD, master) Make db migrate (67 seconds ago)
* e5c1e1d - Add application page ,css , javascript (78 seconds ago)
* b6c5b68 - Add sandbox page (3 minutes ago)
* 7552b76 - Add welcome controller (25 minutes ago)
* 627c6c6 - Add themes folder into projects (54 minutes ago)
* 856c719 - Initial commit (68 minutes ago)

当我跑git rebase --interactive 856c719

然后我在保存之后编辑了以下文件。

我得到了

2_dqa_streesful_server/.git/rebase-merge/stopped-sha: No such file or directory Cannot 'squash' without a previous commit

  1 squash 627c6c6 Add themes folder into projects
  2 pick 7552b76 Add welcome controller
  3 pick b6c5b68 Add sandbox page
  4 squash e5c1e1d Add application page ,css , javascript
  5 pick fc60bec Make db migrate

1 个答案:

答案 0 :(得分:0)

  

git rebase --interactive 856c719

然后将选择替换为壁球,用于您要压缩(合并)的提交:

pick   856c719 Initial commit
squash 627c6c6 Add themes folder into projects
pick   7552b76 Add welcome controller
pick   b6c5b68 Add sandbox page
squash e5c1e1d Add application page ,css , javascript
pick   fc60bec Make db migrate