赞
踩
目的:为文件打补丁
OS:Linux
方法:
diff -uN
patch --p0
具体例子:
file 内容OLD
打补丁为新文件file,内容NEW
方法:
1 分别创建file, fileNew,内容分别是OLD NEW
2 制作补丁
diff file fileNew >this.patch
查看制作的补丁
[root@gdc1000 patch]# cat this.patch
1c1
< OLD
---
> NEW
3 打补丁
patch < this.patch
出错,错误是
patch: **** Only garbage was found in the patch input.
4 查看file的内容,没有变化。
5 重新制作补丁
[root@gdc1000 patch]# diff -u file fileNew > this.patch
[root@gdc1000 patch]# cat this.patch
--- file 2015-04-12 08:57:40.925824818 +0800
+++ fileNew 2015-04-12 08:58:02.853824804 +0800
@@ -1 +1 @@
-OLD
+NEW
[root@gdc1000 patch]# patch < this.patch
[root@gdc1000 patch]# patch < this.patch
patching file file
[root@gdc1000 patch]# cat file
NEW
[root@gdc1000 patch]#
6 git diff is the same to diff files
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。