打補丁、還原補丁
1、兩個commit間的修改(包含兩個commit,<r1>、<r2>表示兩個提交的版本號,<r1>是最近提交)
git format-patch <r1>...<r2> -o C:/patch
2、還原補丁
git am --signoff < C:/patch/0001-.patch
(該補丁保留歷史信息,誰的代碼還是誰的)
其他操作:
1、單個commit
git format-patch -1 <r1>
2、從某commit以來的修改(不包含該commit)
git format-patch <r2>
3、
檢查patch文件
git apply --stat 0001-minor-fix.patch
4、
查看是否能應用成功
git apply --check 0001-minor-fix.patch
5、
應用patch
git am -s < 0001-minor-fix.patch
注:如果把生成的patch文件不在目標git目錄下,使用絕對路徑