Git fixing patches

Is there a way to export a sequence of commits to a patch from Git. Let's say I need to export the last 5 commits from a repository and import them into another repository. How can I do it?

Help with this will be appreciated.

+4
source share
2 answers

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 
+7
source

You can select any range you want using format-patch

 git format-patch --stdout R1..HEAD > output.patch 
+1
source

Source: https://habr.com/ru/post/1433887/


All Articles