git 如何在两个标签之间创建补丁并在它们之间进行多次提交?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9078820/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 12:52:42  来源:igfitidea点击:

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

gitpatch

提问by Rishi

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 在同一个分支中有两个标签。它们之间至少有 5-6 次提交。如何在两个标签之间创建单个补丁,以便将其应用于 GitHub 存储库?

回答by fajran

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

您可以使用以下方法在两个标签之间创建单个差异(补丁)

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

Replace tag1and tag2to the tags you want.

替换tag1tag2到您想要的标签。

回答by Patrick Sanan

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

您可以通过使用该--stdout选项并将输出定向到文件来为多个提交创建单个补丁:

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