How to create patch between two tags with multiple commits between them?

GitPatch

Git Problem Overview


I have two tags in my git in same branch. There are at least 5-6 commits between them. How can I create a single patch between the two tags so that it can be applied to a GitHub repo?

Git Solutions


Solution 1 - Git

You can create a single diff (patch) between two tags using the following

$ git diff tag1 tag2 -- > the-patch.diff

Replace tag1 and tag2 to the tags you want.

Solution 2 - Git

You can create a single patch for multiple commits by using the --stdout option and directing the output to a file:

git checkout tag2
git format-patch tag1 --stdout > patch1to2.patch

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRishiView Question on Stackoverflow
Solution 1 - GitfajranView Answer on Stackoverflow
Solution 2 - GitPatrick SananView Answer on Stackoverflow