如何列出所有Git标签? [英] How to list all Git tags?

查看:88
本文介绍了如何列出所有Git标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的资源库中,我使用以下命令创建了标签。

  git标签v1.0.0 -m'终于稳定版'
git标签v2.0.0 -m'oops ,还有一个重大的错误!'

你如何列出资料库中的所有标签?

解决方案

  git tag 

应该足够了。请参阅 git标记手册页






您还有:

  git tag -l< pattern> 




列表名称与给定模式匹配的标签)
不带参数地输入git tag,也列出了所有的标签。







最近(如何对git标签进行排序?,适用于Git 2.0+)

  git tag --sort =< type> 




按特定顺序排序。



支持的类型为:


  • refname (字典顺序),
  • 版本:refname v:refname (标签名称被视为版本)。



加入 - 可以反转排序顺序。 b






同时列出:

$ ul

  • 带注释的标签 :存储在Git数据库中的完整对象。他们进行了校验和;包含标记名称,电子邮件和日期;有一个标记消息;并且可以使用GNU Privacy Guard(GPG)进行签名和验证。 轻量级标签 :指向现有提交的简单指针


    请注意:关于标记的 git ready文章不支持轻量级标签。


    如果没有参数,git标签会创建一个基本上不会移动的分支。 $ b虽然轻量级标签仍然很有用,可能用于标记已知的好(或不好)版本,或者将来可能需要使用一堆提交。

    尽管如此,你可能不会't想要推送这些类型的标签

    通常,您希望至少通过-a选项来创建未签名标签,或者签署通过-s或-u选项标记您的GPG密钥。







    也就是说, Charles Bailey 指出,' git tag -m...'实际上意味着一个正确的(未注释的注释)标签(选项' -a '),而不是轻量级的。所以你对你的初始命令很好。






    这不同于:

      git show-ref --tags -d 

    其中列出了提交的标签(请参阅 Git标签列表,显示提交sha1哈希)。

    请注意 -d ,以便对带注释的标记对象(具有自己的提交SHA1)进行解引用并显示实际标记的提交。



    同样, git show --name-only< aTag> 会列出标签和相关的提交。


    In my repository, I have created tags using the following commands.

    git tag v1.0.0 -m 'finally a stable release'
    git tag v2.0.0 -m 'oops, there was still a major bug!'
    

    How do you list all the tags in the repository?

    解决方案

    git tag
    

    should be enough. See git tag man page


    You also have:

    git tag -l <pattern>
    

    List tags with names that match the given pattern (or all if no pattern is given).
    Typing "git tag" without arguments, also lists all tags.


    More recently ("How to sort git tags?", for Git 2.0+)

    git tag --sort=<type>
    

    Sort in a specific order.

    Supported type is:

    • "refname" (lexicographic order),
    • "version:refname" or "v:refname" (tag names are treated as versions).

    Prepend "-" to reverse sort order.


    That lists both:

    • annotated tags: full objects stored in the Git database. They’re checksummed; contain the tagger name, e-mail, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG).
    • lightweight tags: simple pointer to an existing commit

    Note: the git ready article on tagging disapproves of lightweight tag.

    Without arguments, git tag creates a "lightweight" tag that is basically a branch that never moves.
    Lightweight tags are still useful though, perhaps for marking a known good (or bad) version, or a bunch of commits you may need to use in the future.
    Nevertheless, you probably don’t want to push these kinds of tags.

    Normally, you want to at least pass the -a option to create an unsigned tag, or sign the tag with your GPG key via the -s or -u options.


    That being said, Charles Bailey points out that a 'git tag -m "..."' actually implies a proper (unsigned annotated) tag (option '-a'), and not a lightweight one. So you are good with your initial command.


    This differs from:

    git show-ref --tags -d
    

    Which lists tags with their commits (see "Git Tag list, display commit sha1 hashes").
    Note the -d in order to dereference the annotated tag object (which have their own commit SHA1) and display the actual tagged commit.

    Similarly, git show --name-only <aTag> would list the tag and associated commit.

    这篇关于如何列出所有Git标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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