git patch

 

[root@localhost libxml2]# patch -pn < 0001-fix-parser-termination-from-Double-hyphen-within-com.patch 
patch: **** strip count n is not a number
[root@localhost libxml2]# git apply --stat 0001-fix-parser-termination-from-Double-hyphen-within-com.patch 
 parser.c |    4 ++++
 1 file changed, 4 insertions(+)
[root@localhost libxml2]# it apply --check   0001-fix-parser-termination-from-Double-hyphen-within-com.patch 
-bash: it: command not found
[root@localhost libxml2]# git apply --check   0001-fix-parser-termination-from-Double-hyphen-within-com.patch 
error: patch failed: parser.c:4955
error: parser.c: patch does not apply
[root@localhost libxml2]# git am --signoff < 0001-fix-parser-termination-from-Double-hyphen-within-com.patch 
Applying: fix parser termination from "Double hyphen within comment" error.
error: patch failed: parser.c:4955
error: parser.c: patch does not apply
Patch failed at 0001 fix parser termination from "Double hyphen within comment" error.
The copy of the patch that failed is found in:
   /data1/cloud_images/libxml2/.git/rebase-apply/patch
When you have resolved this problem, run "git am --resolved".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
[root@localhost libxml2]# 

 

打入 patch / diff:
git apply xxx.patch
git apply xxx.diff
检查 patch / diff:
git apply --check xxx.patch
git apply --check xxx.diff
若git和需要打patch的文件不在一个目录:(git在framework下,patch要打入frameworks/base/下)
git apply --check --directory=base/ xxx.patch
git apply --directory=base/ xxx.patch
** git am 后面会说到,以及生产patch和打入patch的一些命令参数**
  1. 检查patch是否可用,没显示文字,就说明可用,且无冲突;
    git apply --check ~/patch/patch/0001-add-11111.patch


 
链接:https://www.jianshu.com/p/e5d801b936b6
 

posted on 2020-11-04 19:38  tycoon3  阅读(207)  评论(0编辑  收藏  举报

导航