Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ejhayes/5551443 to your computer and use it in GitHub Desktop.
Save ejhayes/5551443 to your computer and use it in GitHub Desktop.
Using git to generate patch files and patch to apply them.
# Take the last 2 commits from git and create a patch file
$ git format-patch -2 HEAD --stdout > 0001-last-2-commits.patch
# Doing a dry run of a patch
$ patch --dry-run -i 0001-last-2-commits.patch -p1
patching file ...
# Actually applying the patch file
$ patch -i 0001-last-2-commits.patch -p1
patching file ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment