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

git format-patch -1

Does the job for me.


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.


Taking from @Useless answer, you can also use the general form with no parameters for the last commit and put it into a file with:

git format-patch HEAD^ --stdout > patchfile.patch

Or, being cleaner for windows users when carets have to be escaped by doubling them:

git format-patch HEAD~1 --stdout > patchfile.patch

another way, if have the commit id of that particular commit, you can use,

git format-patch -1 {commit-id}

Tags:

Git

Patch