Reputation: 764
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.
Upvotes: 4
Views: 3749
Reputation: 154836
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
:
git am < ~/patches
Upvotes: 7
Reputation: 22824
You can select any range you want with format-patch
git format-patch --stdout R1..HEAD > output.patch
Upvotes: 1