linux

linux 打补丁diff 和 patch

diff and patch

文件

  1. shell: diff 1.txt 2.txt > 1-2.patch.
  2. shell: patch 1.txt < 1-2.patch (打补丁)
  3. shell: patch -R 1.txt < 1-2.patch (撤销打补丁)

文件夹

  • -p 的含义:strip the smallest prefix containing num leading slashes from each file name found in the patch file.
    • exmaple : /a/b/c/d/e/f/g
      • p3 的效果去掉第3个/前面的内容: c/d/e/f/g
      • p4 的效果是去掉第4个前面内容
  1. Diff: diff -Nur 1 2 > patch-1-2.patch
  2. patch: patch -p1 < ../patch-1-2.patch (进入目录打补丁)
  3. patch: patch -R -p1 < ../patch-1-2.patch (撤销补丁)
  4. patch: -p0 < patch-1-2.patch(外部目录打补丁)

文件夹内

参考

1.https://m.linuxidc.com/Linux/2017-06/144701.htm?utm_source=tuicool&utm_medium=referral

发表评论

您的电子邮箱地址不会被公开。