如何补丁1个文件(linux diff patch)
2015-04-12 08:54
507 查看
目的:为文件打补丁
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
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
相关文章推荐
- 【linux】利用patch和diff命令制作文件补丁
- 【linux】利用patch和diff命令制作文件补丁
- 【linux】利用patch和diff命令制作文件补丁
- 如何制作patch文件及如何打patch 附带linux打补丁命令
- linux利用patch和diff命令制作文件补丁
- Linux下使用diff/patch制作/使用补丁文件
- 【linux】利用patch和diff命令制作文件补丁
- 如何制作patch文件及如何打patch 附带linux打补丁命令
- 在linux下面比较两个文件及打补丁整理 <diff> - <patch>
- 如何制作LINUX的patch文件及如何打patch
- linux 补丁文件, 一个最简单的patch的格式
- diff命令patch命令及对文件和目录打补丁
- Linux 下 如何打 PATCH 及制作 DIFF
- 如何使用diff命令制作补丁patch命令打补丁
- 制作patch文件 打patch 附带linux打补丁命令
- 如何制作LINUX的patch文件及如何打patch
- linux-vimdiff,diff,patch,cmp:文件比较
- 【转】Linux下使用diff和patch制作及打补丁
- Linux 下 如何打 PATCH 及制作 DIFF
- Linux下使用diff和patch制作及打补丁