当前位置:   article > 正文

如何补丁1个文件(linux diff patch)_patch: **** only garbage was found in the patch in

patch: **** only garbage was found in the patch input.

目的:为文件打补丁

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



声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/559525
推荐阅读
相关标签
  

闽ICP备14008679号