How can I generate a Git patch for a specific commit?


git format-patch -1 <sha>


git format-patch -1 HEAD

According to the documentation link above, the -1 flag tells Git how many commits should be included in the patch;


Prepare patches from the topmost commits.

Apply the patch with the command:

git am < file.patch

Leave a Comment