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?
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.
-
1Btw, by patch file do you mean something like what
git format-patch
produces?– fajranJan 31, 2012 at 12:10 -
1yes i need a patch file like [git format-patch] command produces.Can you tell me how this work between two tags.– RishiFeb 2, 2012 at 5:42
-
2You can squash those commits into one commit using
git rebase
. After you have that one commit, you can usegit format-patch
to create the patch file of it.– fajranFeb 3, 2012 at 9:58
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
-
1