我尝试按照介绍制作补丁这里。
假设我有两个目录pp1(modified version)
,我使用以下命令pp0(clean version)
创建一个补丁文件:pp0.patch
diff
diff -crB pp0 pp1 > pp0.patch
问题是如果只有 pp1 中有一个文件,它不会包含在补丁中。如何解决这个问题?
更新:
我先进入pp0目录,测试一下补丁是否成功
patch --dry-run -p1 -i /path-to-pp0.patch
虽然我已经添加--new-file
到命令中diff
,但那些仅pp1
在结果中没有列出
更新:
我不小心修补了错误的文件,所以
diff -crb --new-file pp1 pp0 > pp0.patch
或者
diff -crNb pp1 pp0 > pp0.patch
会做
答案1
您应该能够使用--new-file
switch 来做到这一点。取自差异手册页:
--new-file
In directory comparison, if a file is found in only one direc-
tory, treat it as present but empty in the other directory.
尝试这个:
diff -crB --new-file pp0 pp1 > pp0.patch