When listing git-ls-remote why there's “^{}” after the tag name?

This question already has an answer here:

  • What does ^{} mean in git?

    2 answers

  • Reverting to previous commit non-destructively
  • Git log: filter by commit's author date
  • git blame: correct author after merge
  • Eclipse: large number of conflicts to resolve
  • How to set up Git source control for matlab?
  • GitLab shows deleted branches
  • Is there a fast way to rebase a long history of commits to master branch?
  • How to create a remote repository via SSH?
  • One Solution collect form web for “When listing git-ls-remote why there's “^{}” after the tag name?”

    There are 2 types of tags – lightweight and annotated. Lightweight tags are merely refs that point to some object whereas annotated tags are a separate git object by themselves, and store a lot more information like author, committer, a commit message, etc.

    When you used git tag -a to create a tag, git would have created an annotated tag for you.

    The ^{} is the syntax used to dereference a tag. It is described in gitrevisions.

    • When used with tag objects, git would recursively dereference the tag until it finds a non-tag object.

    • When used with non-tag objects, it doesn’t do anything and is equivalent to skipping the ^{}

    The refs/tags/v0.1.6 ref in your repository points to the tag object bb944682f7f65272137de74ed18605e49257356c, which in turn points to 771a930dc0ba86769d6862bc4dc100acc50170fa (a non-tag object) which I’m guesssing is storing the commit information when you created the tag.

    So when you do refs/tags/v0.1.6^{}, git is going to dereference the tag and resolve it to 771a930dc0ba86769d6862bc4dc100acc50170fa – the non-tag object.

    There is also a git show-ref command that can be used to list only tags, and optionally dereference as follows, and in your case should produce the following output:

    $ git show-ref --tags
    bb944682f7f65272137de74ed18605e49257356c    refs/tags/v0.1.6
    a72251d945353a360087eb78ee75287c38a1c0e6    refs/tags/v0.1.7
    
    $ git show-ref --tags --dereference
    bb944682f7f65272137de74ed18605e49257356c    refs/tags/v0.1.6
    771a930dc0ba86769d6862bc4dc100acc50170fa    refs/tags/v0.1.6^{}
    a72251d945353a360087eb78ee75287c38a1c0e6    refs/tags/v0.1.7
    d69e66d7c915b9682618b7f304b80cc0ae4c7809    refs/tags/v0.1.7^{}
    

    To confirm this, you can use git show command to give you more details about the git object.

    This is the information from one of my test git repositories.

    $ git show 43f9a98886ba873c0468c608f24c408b9991414f
    tag v0.1
    Tagger: Ash <tuxdude@OptimusPrime>
    Date:   Sun Jul 15 00:14:43 2012 -0700
    
    Tagging Stable repo 0.1 :)
    -----BEGIN PGP SIGNATURE-----
    <PGP-SIGNATURE>
    -----END PGP SIGNATURE-----
    
    commit e55df25f2321a6b2c9a02fa80ccba7cbe3c38c08
    Merge: 796efcd 58e3a4d
    Author: Ash <tuxdude@OptimusPrime>
    Date:   Sun Jul 15 00:02:44 2012 -0700
    
        Merge branch 'dev' into 'master' for stable 0.1.
    
    $ git show e55df25f2321a6b2c9a02fa80ccba7cbe3c38c08
    commit e55df25f2321a6b2c9a02fa80ccba7cbe3c38c08
    Merge: 796efcd 58e3a4d
    Author: Ash <tuxdude@OptimusPrime>
    Date:   Sun Jul 15 00:02:44 2012 -0700
    
        Merge branch 'dev' into 'master' for stable 0.1.
    
    Git Baby is a git and github fan, let's start git clone.