5. 用rebase -i 汇合提交

    为了节省时间,这个教程使用现有的历史记录作为本地数据库。

    下载

    我们进入stepup-tutorial/tutorial5目录。本地端的历史记录的状态如下图显示。在这里汇合「添加commit的讲解」和「添加pull的讲解」的修改,然后合并到一个提交。

    若要汇合过去的提交,请用rebase -i。

    打开文本编辑器,将看到从HEAD到HEAD~~的提交如下图显示。

    1. pick 9a54fd4 添加commit的说明
    2. pick 0d4a808 添加pull的说明
    3.  
    4. # Rebase 326fc9f..0d4a808 onto d286baa
    5. # Commands:
    6. # p, pick = use commit
    7. # r, reword = use commit, but edit the commit message
    8. # e, edit = use commit, but stop for amending
    9. # f, fixup = like "squash", but discard this commit's log message
    10. # x, exec = run command (the rest of the line) using shell
    11. #
    12. # If you remove a line here THAT COMMIT WILL BE LOST.
    13. #

    将第二行的“pick”改成“squash”,然后保存并退出。由于合并后要提交,所以接着会显示提交信息的编辑器,请编辑信息后保存并退出。


    前一页