Often programmers that haven’t worked with patches before find it intimidating. Patches are actually very simple to deal with. Here is how.
Creating Patches
diff -u oldfile newfile > filename.patch
or
diff -urN /olddir /newdir > filename.patch
or
diff -urN -X excludes /olddir /newdir > filename.patch
diff options:
-u Output (default 2) lines of unified context.
-r Recursively compare any subdirectories found.
-N Treat absent files as empty.
-X FILE Exclude files that match any pattern in FILE.
Note: The -u options can be replaced with -c to create a context format diff file with a setting of two lines.
Applying Patches
gzip -cd patch.gz | patch -p0
or
bzip2 -dc patch.bz2 | patch -p0
or
patch -p0 < filename.patch
patch options:
-p NUM Strip NUM leading components from file names.
