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

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

问题描述

如果我想标记当前提交。我知道以下两个命令行都适用:

  git tag< tagname> 

  git标记-a<标记名称> -m'< message>'

这些命令之间有什么区别?

解决方案

TL; DR



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



更多关于轻量级标记



默认情况下,除非您为签名标记选择-s标记,否则该标记将是一个轻量级的未签名标记。使用 git tag<标记名>> $ c>,Git会在当前版本中创建一个标签,但不会提示您注释。当你使用 git tag -a<标签名称> 时,Git会提示你输入注释,除非您还使用了-m标志来提供消息。

  • 当您使用 git tag -a -m< msg>时, < tagname> ,Git将标记提交并使用提供的消息对其进行注释。 ; MSG> < tagname> ,Git的行为就如同您传递注解的-a标志并使用提供的消息一样。


    基本上,这相当于您是否希望轻量级代码具有与其关联的注释。


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

    git tag <tagname>
    

    and

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

    What is the difference between these commands?

    解决方案

    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.

    More About Lightweight Tags

    Unless you select the -s flag for a signed tag, the tag will be a lightweight, unsigned tag by default. There are also some differences with lightweight tags:

    • 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.
    • 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 lightweight tag to have an annotation associated with it or not.

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

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