Skip to content

Instantly share code, notes, and snippets.

@tomasdev
Last active January 21, 2020 12:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomasdev/db32e6f1e47e258039faba687ae16b56 to your computer and use it in GitHub Desktop.
Save tomasdev/db32e6f1e47e258039faba687ae16b56 to your computer and use it in GitHub Desktop.
Guide to patch - diff (How to use patch)
# Create a patch file
diff -u file.old file.new > file.patch
# Apply a patch
patch < file.patch
# Create a backup before applying patch
patch -b < file.patch
# Create a versioned backup before applying patch
# Note: numbered is the mechanism -V uses, not free input
patch -b -V numbered < file.patch
# Validate patch without applying
patch --dry-run < file.patch
# Reverse patch (undo)
patch -R file.old < file.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment