Creating patch file in Mac OS

If you don't want to use VCS for creating patch then you can use diff tool. You can create patch for one file using

diff -u original.c new.c > original.patch


diff -rupN original/ new/ > original.patch

For entire folder

Apply patch

If you are patching  from the root directory and use the -p0 parameter to patch. This will stop patch from asking you which file you wish to patch:

$ patch -p0 < example.patch

If your patch is patching files that mention a & b directories in the patch, you can use the -p1 parameter to get rid of the a/b directories.

$ patch -p1 < example.patch

To fix code style issues in the patch, you can use tab2space like so:

tab2space -unix -t2 foo.patch | patch -p0