Patch

C’est juste une cheat-sheet car je ne me rappelle jamais comment on doit procéder. J’en profite pour coller ici un moyen de faire la différence entre 2 répertoires. Attention, j’ai pas creusé ni encore compris ces histoire de p0, P1… (voir dernier lien au bas de cette page)

Différence entre 2 répertoires

git diff --no-index dir1/ dir2/                 # forcément faut git sur la machine
diff -qrN dir1/ dir2/

Sur un fichier

Apply

patch foo.c < my.patch                   # the patch "knows" the name of the file to be patched

Undo

patch -R < /path/to/file

Create

diff -u hello.cpp hello-new.cpp > my.patch
cat my.patch
patch < hello.patch                      # the patch "knows" the name of the file to be patched

Sur un répertoire

Faire une copie

cp -R origin new_version

Faire des changements

cd new_version
...

Créer le patch

cd ..
diff -Naur origin new_version > my.patch

Appliquer le patch

cp -R origin origin_bak
patch --dry-run -ruN -d origin < my.patch
patch -ruN -d origin < my.patch

Lire


Back to top

Published on: Nov 30 2023 at 03:22 PM | Last updated: Nov 30 2023 at 03:35 PM

Copyright © 1964-2025 - 40tude