Git patch cheatsheet
I always forget how to generate git patches and need to search for the right commands. This is a collection of useful commands and their source.
git format-patch -1 <sha>
git apply --stat file.patch # show stats.
git apply --check file.patch # check for error before applying.
git am < file.patch # apply the patch finally.To generate the patches from the topmost commits from a specific SHA1 hash:
git format-patch -<n> <SHA1>The last 10 patches from head in a single patch file:
git format-patch -10 HEAD --stdout > 0001-last-10-commits.patch