Git Patch

Git patches are text files that contain code and Git commit metadata.

Generate a Git Patch For a Specific Commit

Generate a patch for the HEAD commit:

git format-patch -1 HEAD

Generate a patch for the HEAD commit with specified file name:

git format-patch -1 HEAD --output=head.patch

Generate a patch for HEAD - n commits:

git format-patch -<n> HEAD

Apply the patch with verbose:

git apply --verbose *.patch