How to tell which commit a tag points to in Git ?

How to tell which commit a tag points to in Git ?

Asked on January 8, 2019 in Git.
Add Comment


  • 4 Answer(s)

    One way to give the output for this commit  and tag points with  git rev-list. 

    $ git rev-list -n 1 $TAG
    

    add it as an alias in ~/.gitconfig.

    [alias]
    tagcommit = rev-list -n 1
    

    And then,

    $ git tagcommit $TAG
    
    Answered on January 8, 2019.
    Add Comment

    Try this alternative below code:

    git show-ref --tags
    

    Git show-ref –abbrev=7 –tags

    f727215 refs/tags/v2.16.0
    56072ac refs/tags/v2.17.0
    b670805 refs/tags/v2.17.1
    250ed01 refs/tags/v2.17.2
    
    Answered on January 8, 2019.
    Add Comment

    Use this  git show <tag>

    To exclude those diffs, use git log -1 <tag>.

    Answered on January 8, 2019.
    Add Comment

    One way to do this would be with git rev-list. The following will output the commit to which a tag points:

    $ git rev-list -n 1 $TAG
    

    You could add it as an alias in ~/.gitconfig if you use it a lot:

    [alias]
      tagcommit = rev-list -n 1
    

    And then call it with:

    $ git tagcommit $TAG
    
    Answered on March 5, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.