为什么我应该关心轻量级与注释标签? [英] Why should I care about lightweight vs. annotated tags?

查看:95
本文介绍了为什么我应该关心轻量级与注释标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

去年我从日常VCS切换到了Git,并且仍然在努力掌握Git-think的更精细的部分。



最近一直困扰我的那个是轻量级,而不是注释与签名标签。看起来普遍接受的是,注释标签在所有实际用途上都优于轻量级标签,但是我发现为什么这种情况下的解释总是归结为因为它们不同。不幸的是,那些不了解为什么是最佳实践或者这些差异与我的Git用法有什么相关是非常令人满意的争论。



当我第一次切换到Git时,轻量级标签似乎是自切片面包以来最好的东西;我可以指出一个提交并说那是1.0。我无法理解标签如何超过这个标签,但我绝对不能相信世界上的Git专家更喜欢任意使用注释标签!那么,什么是喧哗?



(积分:为什么我需要签署标签?)



编辑



我一直在成功说服注释标签是一件好事 - 知道谁标记以及何时重要!作为后续工作,有关良好标记注释的任何建议? git tag -am标记1.01.0 并尝试总结提交日志,因为之前的标记感觉像是失败策略。

解决方案

标注标签的优点在于您知道是谁创建的。就像提交,有时很高兴知道是谁做的。如果您是开发人员,并且您看到v1.7.4已被标记(已准备好)并且您不太确定,那么您与谁交谈?名字在注释标签中的人! (如果你生活在一个不信任的世界里,这也会让人们避免去标记他们不应该做的事情)。如果你是一个消费者,那么这个名字就是一个权威的印记:那是Junio Hamano说这个版本的git是在这里其他元数据也可以提供帮助 - 有时知道该版本何时发布,而不仅仅是最终提交的时间是很好的。有时候这个信息甚至可能是有用的。也许它有助于解释特定标签的用途。也许候选版本的标签包含了一些状态/待办事项列表。



签名标签与签署其他任何东西非常相似 - 它提供了更多级别的为偏执狂提供安全保障。我们大多数人都不会使用它,但是如果您在将该软件放入计算机之前确实需要验证所有内容,您可能需要它。



编辑:

至于在标签注释中写什么,你说的没错 - 没什么用处。对于版本号标记,隐含地理解它标记了该版本,并且如果您对其他地方的更新日志感到满意,则不需要在其中放置一个。在这种情况下,最重要的是标签和日期。我能想到的唯一一件事就是从测试套件中获得批准。看看git.git的标签:他们都只是说一些像Git 1.7.3 rc1;我们真正关心的是Junio Hamano的名字。

然而,对于命名不太明显的标签,信息可能变得更加重要。我可以设想为单个用户/客户端标记特定的专用版本,一些重要的非版本里程碑,或者(如上所述)为具有额外信息的候选版本添加标签。这条消息更有用。


I switched from Subversion to Git as my day-to-day VCS last year and am still trying to grasp the finer points of "Git-think".

The one which has been bothering me lately is "lightweight" vs. annotated vs. signed tags. It seems pretty universally accepted that annotated tags are superior to lightweight tags for all real uses, but the explanations I've found for why that's the case always seem to boil down to either "because best practices" or "because they're different". Unfortunately, those are very unsatisfying arguments without knowing why it's best practices or how those differences are relevant to my Git usage.

When I first switched to Git, lightweight tags seemed to be the best thing since sliced bread; I could just point at a commit and say "that was 1.0". I'm having trouble grasping how a tag could ever need to be more than that, but I certainly can't believe that the Git experts of the world prefer annotated tags arbitrarily! So what's all the hubbub about?

(Bonus points: Why would I ever need to sign a tag?)

EDIT

I've been successfully convinced that annotated tags are a Good Thing — knowing who tagged and when is important! As a follow-up, any advice on good tag annotations? Both git tag -am "tagging 1.0" 1.0 and trying to summarize the commit log since the previous tag feel like losing strategies.

解决方案

The big plus of an annotated tag is that you know who created it. Just like with commits, sometimes it's nice to know who did it. If you're a developer and you see that v1.7.4 has been tagged (declared ready) and you're not so sure, who do you talk to? The person whose name is in the annotated tag! (If you live in a distrustful world, this also keeps people from getting away with tagging things they shouldn't.) If you're a consumer, that name is a stamp of authority: that's Junio Hamano saying this version of git is hereby released.

The other metadata can be helpful too - sometimes it's nice to know when that version was released, not just when the final commit was made. And sometimes the message can even be useful. Maybe it helps explain the purpose of that particular tag. Maybe the tag for a release candidate contains a bit of a status/to-do list.

Signing tags is pretty much like signing anything else - it provides one more level of security for the paranoid. Most of us aren't ever going to use it, but if you really want to verify everything before you put that software on your computer, you might want it.

Edit:

As for what to write in a tag annotation, you're right - there's not always much useful to say. For a version number tag, it's implicitly understood that it marks that version, and if you're happy with your changelogs elsewhere, there's no need to put one there. In this case, it's really the tagger and date that are the most important. The only other thing I can think of is some sort of stamp of approval from a test suite. Have a look at git.git's tags: they all just say something like "Git 1.7.3 rc1"; all we really care about is Junio Hamano's name on them.

However, for less obviously named tags, the message could become much more important. I could envision tagging a specific special-purpose version for a single user/client, some important non-version milestone, or (as mentioned above) a release candidate with extra information. The message is then much more useful.

这篇关于为什么我应该关心轻量级与注释标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆