使用 git 生成patch和使用patch

使用 git 生成patch和使用patch
1、没有commit之前
1)制造patch

git status
(1) git diff > patchname
(2) git diff –cached > patchname
(3) git diff branchname –cached > patchname

以上均可
这个是非git 环境也可以使用的patch
2)使用patch

(1)git apply patch
(2) patch -p1 < patchname
2、commit之后
1)制造patch

git log 查看 提交的commit 节点

commit a节点
commit b节点
commit c节点

(1)某次提交以后的所有patch:
git format-patch 4e16 –4e16指的是commit名
(2)从根到指定提交的所有patch:
git format-patch –root 4e16
(3)从根到指定提交的所有patch:
git format-patch –root 4e16
(4)某两次提交之间的所有patch:
git format-patch 365a..4e16 –365a和4e16分别对应两次提交的名称
(5)某次提交(含)之前的几次提交:
git format-patch –n 07fe –n指patch数,07fe对应提交的名称
故,单次提交即为:
git format-patch -1 07fe
2)使用patch

先检查patch文件:git apply –stat newpatch.patch
检查能否应用成功:git apply –check newpatch.patch
打补丁:git am ( –signoff) < newpatch.patch
3、常遇到问题
1)fatal: empty ident name (for <>) not allowed

git config –global user.email “you@example.com”
git config –global user.name “Your Name”
2) .git/rebase-apply still exists but mbox given

git am –abort命令将git的状态恢复到之前状态就可以继续提交patch了
————————————————
版权声明:本文为CSDN博主「静水鱼游」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_27061049/article/details/77678048

版权声明:
作者:bin
链接:https://ay123.net/mystudy/662/
来源:爱影博客
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
海报
使用 git 生成patch和使用patch
使用 git 生成patch和使用patch1、没有commit之前1)制造patch git status(1) git diff > patchname(2) git diff –cached > patchname(3) git diff b……
<<上一篇
下一篇>>