diff patch打补丁
diff
and patch
are tools to create patches and apply patches to source code, which is widely used in the open-source world, such as Linux kernel and application.
diff
和patch
的工具来创建补丁和应用补丁源代码,这是广泛使用的开源世界,如Linux的内核和应用。
补丁:应用补丁 (patch: applying patches)
To apply a patch to a single file:
要将修补程序应用于单个文件:
$ patch < foo.patch
If the foo.patch does not identify the file the patch should be applied to, you can specify the file:
如果foo.patch无法识别应将补丁应用到的文件,则可以指定文件:
$ patch foo.txt < bar.patch
Applying patches to a directory:
将补丁应用到目录:
$ patch -p1 < bar.patch
Here, we set a “p level”. The p level specifies the parts of the path name to ignore by path.
在这里,我们设置一个“ p电平”。 p级别指定按路径忽略的路径名称部分。
For example, the bar.patch applies patches to:
例如,bar.patch将补丁应用于:
/home/eric/package/src/mm/mm.c
/home/eric/package/src/mm/mm.c
To apply the patches correctly in directory src:
要在目录src中正确应用补丁,请执行以下操作:
$ patch -p3 < bar.patch
To remove a patch:
删除补丁:
$ patch -p5 -R < bar.patch
差异:创建补丁 (diff: creating patches)
To create a patch for a single file:
为单个文件创建补丁:
$ diff -u original.c new.c > patch-to-file.patch
To create a patch for a source tree:
为源树创建补丁:
$ diff -rupN original/ new/ > patch-to-dir.patch
Here, original is the original source tree and new is the new source tree that you have changed.
在这里,original是原始的源树,而new是您已更改的新的源树。
有关差异和补丁的更多信息 (More about diff and patch)
Read the man pages for more information about diff
and patch
:
阅读手册页以获取有关diff
和patch
更多信息:
diff手册页 。
修补手册页 。
翻译自: https://www.systutorials.com/diff-and-patch-generating-and-applying-patches/
diff patch打补丁