带注释的标签和未注释的标签有什么区别? [英] What is the difference between an annotated and unannotated tag?

查看:28
本文介绍了带注释的标签和未注释的标签有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想标记当前提交.我知道以下两个命令行都有效:

If I want to tag the current commit. I know both of the following command lines work:

git tag <tagname>

git tag -a <tagname> -m '<message>'

这些命令有什么区别?

推荐答案

TL;DR

命令之间的区别在于,一个命令为您提供标签消息,而另一个命令则不提供.带注释的标签有一条可以用 git-show(1) 显示的消息,而没有注释的标签只是一个指向提交的命名指针.

TL;DR

The difference between the commands is that one provides you with a tag message while the other doesn't. An annotated tag has a message that can be displayed with git-show(1), while a tag without annotations is just a named pointer to a commit.

根据文档:创建一个轻量级标记,不提供任何 -a、-s 或 -m 选项,只需提供标记名称".还有一些不同的选项可以在带注释的标签上写消息:

According to the documentation: "To create a lightweight tag, don’t supply any of the -a, -s, or -m options, just provide a tag name". There are also some different options to write a message on annotated tags:

  • 当你使用 git tag <tagname> 时,Git 会在当前版本创建一个标签,但不会提示你输入注释.它将被标记而没有消息(这是一个轻量级标记).
  • 当你使用 git tag -a <tagname> 时,Git 会提示你输入注释,除非你也使用了 -m 标志来提供消息.
  • 当你使用 git tag -a -m <msg><tagname>,Git 将标记提交并使用提供的消息对其进行注释.
  • 当你使用 git tag -m <msg><tagname>,Git 的行为就像你传递了 -a 标志进行注释并使用提供的消息一样.
  • When you use git tag <tagname>, Git will create a tag at the current revision but will not prompt you for an annotation. It will be tagged without a message (this is a lightweight tag).
  • When you use git tag -a <tagname>, Git will prompt you for an annotation unless you have also used the -m flag to provide a message.
  • When you use git tag -a -m <msg> <tagname>, Git will tag the commit and annotate it with the provided message.
  • When you use git tag -m <msg> <tagname>, Git will behave as if you passed the -a flag for annotation and use the provided message.

基本上,它只是你是否希望标签具有注释和与之相关的一些其他信息.

Basically, it just amounts to whether you want the tag to have an annotation and some other information associated with it or not.

这篇关于带注释的标签和未注释的标签有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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