Git commit patches
Is there a way to export a sequence of commits into a patch from Git. Say I need to export the last 5 commits from a repository and import them into another repository. How would I go about doing that?
Help with this would be appreciated.
2 Solutions collect form web for “Git commit patches”
git format-patch is designed for that purpose:
git format-patch --stdout HEAD~5 > ~/patches
The output is a readable BSD-mailbox-style file that contains patches along with some metadata such as the commit messages. To import the patches into the other repository, use
git am < ~/patches
You can select any range you want with format-patch
git format-patch --stdout R1..HEAD > output.patch