生成補丁
# git format-patch -M master // 當前分支所有超前master的提交
# git format-patch -s hash_code // 某次提交以後的所有patch, --hash_code指的是SHA1 ID
# git format-patch -1 hash_code // 單次提交
# git format-patch -3 // 從master往前3個提交的內容,可修改爲你想要的數值
# git format-patch –n 07fe // -n指patch數,07fe對應提交的名稱, 某次提交(含)之前的幾次提交
# git format-patch -s --root origin // 從origin到指定提交的所有patch
應用補丁
先檢查patch文件:# git apply --stat newpatch.patch
檢查能否應用成功:# git apply --check newpatch.patch
打補丁:# git am --signoff < newpatch.patch
(使用-s或--signoff選項,可以commit信息中加入Signed-off-by信息)
查看某版更新涉及到的文件
#git diff --name-only OLD_COMMIT_ID_HERE NEW_COMMIT_ID_HERE