Skip to content

Instantly share code, notes, and snippets.

@hamelin
Last active March 3, 2020 20:26
Show Gist options
  • Save hamelin/4b47b6468e4c72b852052752966513b8 to your computer and use it in GitHub Desktop.
Save hamelin/4b47b6468e4c72b852052752966513b8 to your computer and use it in GitHub Desktop.
How to extract a patch file describing the change between present (`HEAD`) and an older commit in a Git repo.
# From source repository
cd repo
git diff-index --patch --binary --full-index <commit ID, included>^
# The patch is dumped to standard output. We capture it (to file, to clipboard) and
# send it to the destination host.
# Into source repository
cd repo
git apply <path to patch file>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment