git format-patch -n HEAD
where n is how many commits should be included in the patch
Apply the patch with the command:
git am < file.patch
> Applying patches using patch command:
patch -p1 < <patch-name>
Validate the patch without applying:
patch -p1 --dry-run < <patch-name>