How do I simply create a patch from my latest git commit?


I am looking for the command for creating a patch from the last commit made.

My workflow sometimes looks like this:

vi some.txt
git add some.txt
git commit -m "some change"

Now I just want to write:

git create-patch-from-last-commit-to-file SOME-PATCH0001.patch

What should I put there instead of create-patch-from-last-commit-to-file?


In general,

git format-patch -n HEAD^

(check help for the many options), although it’s really for mailing them.
For a single commit just

git show HEAD > some-patch0001.patch

will give you a useable patch.

Answered By – Useless

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published