git patch 的制作和使用
# 生成patch
git format-patch -1
# -1表示最后一次提交,-o表示补丁文件输出的目录
git format-patch -1 -o /root/patch/
# 将最近5次提交制作成补丁
git format-patch -5 -o /root/patch/
# 将该次提交制作补丁
git format-patch de85add54522b7ca3b7ad99c7c5ea24525d39ba0 -o /root/patch/
# 将该次提交之前的3个提交(含本次提交)制作成bud
git format-patch -3 de85add54522b7ca3b7ad99c7c5ea24525d39ba0 -o /root/patch/
# 两个commit间的修改
git format-patch 7f581e5fabbed21ad8c8ccd3398513d626f01ecf...de85add54522b7ca3b7ad99c7c5ea24525d39ba0e919cd7a -o /root/patch/
# 检查patch(补丁)文件
git apply --stat /root/patch/0001-test-fix.patch
# 查看是否可以应用成功
git apply --check /root/patch/0001-test-fix.patch
# 进行实际的应用,此时补丁代码会合并到代码树中
git am -s < /root/patch/0001-test-fix.patch
# 应用patch
git am /root/patch/0001-test-fix.patch
# 打单个补丁
git apply commit.patch
# 打多个补丁
git apply ../patch/*.patch