Skip to content

Instantly share code, notes, and snippets.

@compor
Created February 25, 2013 15:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save compor/5030424 to your computer and use it in GitHub Desktop.
Save compor/5030424 to your computer and use it in GitHub Desktop.
create and apply a patch between files in two directories
# produces a patch between the files in the 2 dirs
# -c : special context for output
# -r : directory recursively
# -B : ignore blanks
diff -crB before_dir after_dir > foo.patch
# if you want to patch before_dir now
cd before_dir
# -p n : strip the smallest prefix containing n number of slashes
# you can do a dry run by adding --dry-run
# or use a backup of the file before it gets patched with -b
patch -p1 < ../foo.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment