Skip to content

Instantly share code, notes, and snippets.

@Integralist
Last active April 16, 2019 02:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Integralist/13d9f5e8ec197e5e53c6 to your computer and use it in GitHub Desktop.
Save Integralist/13d9f5e8ec197e5e53c6 to your computer and use it in GitHub Desktop.
Get a git diff and apply git diff using gist ruby gem -> https://github.com/defunkt/gist (also see this alternative using `git format-patch`: https://gist.github.com/Integralist/87852ced09d7918322c0)
git show HEAD HEAD~1 # (or use a hash instead: `git show {commit} {commit} {commit}`)
git diff --cached | gist -p -f test.diff
curl https://gist.githubusercontent.com/anonymous/x/raw/x/test.diff | git apply
curl https://gist.githubusercontent.com/anonymous/x/raw/x/test.diff | git apply --reverse
@Integralist
Copy link
Author

You can also generate a patch from a GitHub URL by adding a .patch extension to the end of a PR path or commit path.

Then you can do a shortcut apply of the patch:

git am < foo.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment