Git Tag list, display commit sha1 hashes

后端 未结 8 1139
无人共我
无人共我 2020-12-12 17:56

so the git tag command lists the current git tags

tag1
tag2

git tag -n prints tag\'s message

tag1         


        
8条回答
  •  一个人的身影
    2020-12-12 18:27

    I had a similar question, but wanted the hash of (several) specific tags. I found that "show-ref" will take a list of tags, so this does the job:

    % git show-ref v3.4.0.13-ga v3.4.0.13-base
    bfc7747c4cf67a4aacc71d7a40337d2c3f73a886 refs/tags/v3.4.0.13-base
    79ba365e75a4f9cee074d25a605a26acb660b7de refs/tags/v3.4.0.13-ga
    

    However, some experimentation with "git show" resulted in this command:

    % git show --summary --oneline --decorate v3.4.0.13-ga v3.4.0.13-base
    79ba365 (tag: v3.4.0.13-ga, rhins013a) commit message the first
    bfc7747 (tag: v3.4.0.13-base) commit message the second
    

    Since I'm much more familiar with using "show" than "show-ref", I find the latter easier to remember and more helpful too.

    See also the nice summary in How to tell which commit a tag points to in Git?.

提交回复
热议问题