Merge all commits from the long-feature-branch as a single commit.
把名為 long-feature-branch 的分支合并到主干,把分支中的多次提交合并為主干上的一次提交。
在第38關(guān)我們曾學(xué)習(xí)過 merge
合并,它的語法是:
$ git merge branch-name
如果分支曾經(jīng)提交過多次,那么用上面的語句合并之后,主干的日志也會出現(xiàn)多次提交記錄。為了符合本關(guān)題意,把分支的多次提交合并為主干上的一次提交,要加一個 squash
參數(shù),如下:
$ git merge branch-name --squash
如果不加 squash
參數(shù),在合并之后系統(tǒng)會默默地做一個 commit
操作,而加了 squash
參數(shù)之后,不會自動 commit
,這時你還需要手動執(zhí)行 commit
命令,并且寫上提交說明。
第46關(guān)過關(guān)畫面如下:
http://wiki.jikexueyuan.com/project/githug-walkthrough/images/level-46-merge-squash.png" alt="第46關(guān) merge_squash" />