git format-patch is for this purpose:
git format-patch --stdout HEAD~5 > ~/patches
The output file is a readable BSD-mailbox style file that contains corrections along with some metadata, such as commit messages. To import patches into another repository, use git am :
git am < ~/patches
source share