可以透過git來產生patch檔給其他使用同一個版本庫的使用者
patch產生的範圍有下面的方式可以設定
git format-patch --root
git format-patch -n
git format-patch 5e86795..f2b286a
-o 可以設定輸出的資料夾
$ git format-patch 5e86795..f2b286a -o /Users/morrishsu/Documents/20170103Patch
/Users/morrishsu/Documents/20170103Patch/0001-modify-page.patch
/Users/morrishsu/Documents/20170103Patch/0002-learn-git.patch
/Users/morrishsu/Documents/20170103Patch/0003-modify-div.patch
/Users/morrishsu/Documents/20170103Patch/0004-prepare.patch
/Users/morrishsu/Documents/20170103Patch/0005-add-div-element.patch
/Users/morrishsu/Documents/20170103Patch/0006-deBug.patch
/Users/morrishsu/Documents/20170103Patch/0007-Bug-fixed.patch
/Users/morrishsu/Documents/20170103Patch/0008-master-keep-going.patch
/Users/morrishsu/Documents/20170103Patch/0009-commit-stash-data.patch
/Users/morrishsu/Documents/20170103Patch/0010-Revert-Bug-fixed.patch
可以發現他把commit都做成.patch檔案了
再下git am指令前記得要先下git am --abort
git am --abort
可以取消之前匯入失敗的結果
可以整個資料夾匯入,它會根據檔名前面的數字的先後順序來匯入
git am /Users/morrishsu/Documents/20170103Patch/*
也可以一個一個patch匯入
git am 0001-modify-page.patch
patch過程遇到有衝突問題後,一樣要解決衝突之後再繼續進行git am
直到完成patch