1. 程式人生 > >git 某次提交補丁的生成與應用 (patch)

git 某次提交補丁的生成與應用 (patch)

使用gitformat-patch生成所需要的patch:

# git format-patch -s1bbe3c8c197a35f79bfddaba099270a2e54ea9c7

please replace the hash code with your repo previous commit.

then you can find the patch under repo directory.

then mail your patch to configuration admin. 


# gitformat-patch -M master       // 當前分支所有超前master的提交 # gitformat-patch -s 4e16
             // 某次提交以後的所有patch, 
--4e16指的是SHA1ID
# gitformat-patch -1                 //  單次提交
# git format-patch -3                 //從master往前3個提交的內容,可修改為你想要的數值 # gitformat-patch –n 07fe          // -n指patch數,07fe對應提交的名稱, 某次提交(含)之前的幾次提交
gitformat-patch -s --rootorigin    // 從origin到指定提交的所有patch 應用patch:
先檢查patch檔案:
# gitapply --stat newpatch.patch

檢查能否應用成功:# gitapply --check newpatch.patch
打補丁:# git am --signoff <newpatch.patch

(使用-s或--signoff選項,可以commit資訊中加入Signed-off-by資訊)

git am

http://blog.csdn.net/mliubing2532/article/details/7577905

http://blog.csdn.net/yuyin86/article/details/8087057