Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

patch

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?

like image 288
Rishi Avatar asked Jan 31 '12 11:01

Rishi


People also ask

How do you make a patch of a commit?

In order to create Git patch file for a specific commit, use the “git format-patch” command with the “-1” option and the commit SHA. In order to get the commit SHA, you have to use the “git log” command and look for the corresponding commit SHA.

How do I find the difference between two commits in git?

To see the changes between two commits, you can use git diff ID1.. ID2 , where ID1 and ID2 identify the two commits you're interested in, and the connector .. is a pair of dots. For example, git diff abc123.. def456 shows the differences between the commits abc123 and def456 , while git diff HEAD~1..

Why is git apply skipping patch?

A patch is usually skipped when the changes it contains were already applied in the past. There are many possible reasons for this: a merge, a cherry-pick, changes operated manually or using another patch etc.


2 Answers

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.

like image 191
fajran Avatar answered Sep 21 '22 14:09

fajran


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 
like image 25
Patrick Sanan Avatar answered Sep 19 '22 14:09

Patrick Sanan