I just had this same problem – lots of advice on how to half do it. Well, here is what I did to get both the patching and unpatching to work:
To Create the Patch File:
-
Put copies of both directories in say /tmp, so we can create the patch
file, or if brave, get them side by side – in one directory. -
Run an appropriate diff on the two directories, old and new:
diff -ruN orig/ new/ > file.patch # -r == recursive, so do subdirectories # -u == unified style, if your system lacks it or if recipient # may not have it, use "-c" # -N == treat absent files as empty
If a person has the orig/ directory, they can recreate the new one by running patch.
To Recreate the new folder from old folder and patch file:
-
Move the patch file to a directory where the orig/ folder exists
-
This folder will get clobbered, so keep a backup of it somewhere, or
use a copy.patch -s -p0 < file.patch # -s == silent except errors # -p0 == needed to find the proper folder -
At this point, the orig/ folder contains the new/ content, but still
has its old name, so:mv orig/ new/ # if the folder names are different