1. 程式人生 > >Git 合並多個commit 和 cherry-pick的使用

Git 合並多個commit 和 cherry-pick的使用

-c mit article -abort 開始 撤銷 修改 進入 錯誤

合並多個commit

1、三個commit合並

    git rebase -i commit_id

    其中,-i 的參數是不需要合並的 commit 的 hash 值,這裏指的是第一條 commit, 接著我們就進入到 vi 的編輯模式

2、pick 和 squash 選擇

    pick 的意思是要會執行這個 commit

    squash 的意思是這個 commit 會被合並到前一個commit

註意事項:如果這個過程中有操作錯誤,可以使用 git rebase --abort來撤銷修改,回到沒有開始操作合並之前的狀態。

合並另一個分支的某一個commit

  git cherry-pick 009d3ce(commit_hash,另一個分支,也可以是本分支的某一個提交)

Git 合並多個commit 和 cherry-pick的使用