3.2. patch - apply a diff file to an original

简介:

diff

-r 是一个递归选项,设置了这个选项,diff会将两个不同版本源代码目录中的所有对应文件全部都进行一次比较,包括子目录文件。

-N 选项确保补丁文件将正确地处理已经创建或删除文件的情况。

-u 选项以统一格式创建补丁文件,这种格式比缺省格式更紧凑些。

patch

-p0 选项要从当前目录查找目的文件(夹)

-p1 选项要忽略掉第一层目录,从当前目录开始查找。

-E 选项说明如果发现了空文件,那么就删除它

-R 选项说明在补丁文件中的“新”文件和“旧”文件现在要调换过来了(实际上就是给新版本打补丁,让它变成老版本)

例 3.1. single file

make a patch file

$ diff -uN file.old file.new > file.patch
			

take a patch file

			
$ patch -p0 < file.patch
			
			


例 3.2. a lot of file or directory

$ diff –uNr dir.old dir.new >my.patch
			

			
$ patch -p1 < file.patch
			
			





原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

目录
相关文章
|
7月前
|
iOS开发
Xcode报错“compact unwind compressed function offset doesn‘t fit in 24 bits
Xcode报错“compact unwind compressed function offset doesn‘t fit in 24 bits
70 1
|
7月前
|
Linux
diff与patch的使用
diff与patch的使用
66 1
|
移动开发
diff和patch的使用简介
diff和patch的使用简介
perhaps your file is in a different file format and youneed to use a different restore operator?
perhaps your file is in a different file format and youneed to use a different restore operator?
167 0
|
TensorFlow 算法框架/工具
成功解决To fix this you could try to: 1. loosen the range of package versions you‘ve specified ​​​​​​​
成功解决To fix this you could try to: 1. loosen the range of package versions you‘ve specified ​​​​​​​
成功解决To fix this you could try to: 1. loosen the range of package versions you‘ve specified ​​​​​​​
|
Linux Perl 开发工具

热门文章

最新文章