合并之前或之后的 Git 标记?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12594919/
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 14:40:17  来源:igfitidea点击:

Git tag before or after merge?

gitgit-tag

提问by user1699176

I have a simple question about tagging different versions of my project with git. If I just completed my 1.1 branch and plan to merge it into master, should I tag this branch as 1.1 before I merge it, or should I merge it to master and then tag it as 1.1? Would it make a difference either way? Maybe one way is preferred? Thanks.

我有一个关于用 git 标记我的项目的不同版本的简单问题。如果我刚刚完成了我的 1.1 分支并计划将其合并到 master 中,我应该在合并之前将该分支标记为 1.1,还是应该将其合并到 master 然后将其标记为 1.1?无论哪种方式都会有所不同吗?也许一种方式是首选?谢谢。

采纳答案by Amber

Depends. Will the branch fast-forward into master?

要看。分支会快进master吗?

If the answer is 'yes' then it doesn't matter whether you tag it before or after doing the fast-forward merge, because the tagged commit will be the same either way.

如果答案是“是”,那么在进行快进合并之前或之后标记它都没有关系,因为无论哪种方式标记的提交都是相同的。

If the answer is 'no', then you should probably tag it after merging into master(assuming you cut releases from master). In general you want your tags to match your releases (to make it easier to look at the version of the code that was released), so you tag the version in the place you're making releases from.

如果答案是“否”,那么您可能应该在合并后标记它master(假设您从 中删除了发布master)。通常,您希望您的标签与您的发布相匹配(以便更容易查看已发布代码的版本),因此您可以在发布版本的位置标记版本。

回答by nevsan

It all depends on your distribution model. If 'master' is your main release line, I would imagine that 1.1 isn't really 'done' until it successfully merges into the main line, in which case, you should tag after merge.

这一切都取决于您的分销模式。如果 'master' 是你的主要发布线,我想 1.1 在它成功合并到主线之前并没有真正“完成”,在这种情况下,你应该在合并后标记。

Note:I've seen some projects use master as a dev branch and then have separate branches for 'stable' versions (not a model that I agree with). In the this case, you tag before merge.

注意:我看到一些项目使用 master 作为开发分支,然后为“稳定”版本(不是我同意的模型)设置单独的分支。在这种情况下,您在合并之前标记。