1

What is the meaning of the symbol ^{}?
If I check with git log or github the tag reference to the commit in the lines with this symbol, so what is the duplicate object without this symbol.

Example

2191702bddc9438e2e8beda602972fdb87a73a15        refs/tags/V1.0
0bfeb6f7a1d2789b3e3d9944edbe680cd7355b6a        refs/tags/V1.0^{}
6bde933efef11bbc75f71df2111b146748220ad8        refs/tags/V2.0
de33c8da37dba18f8d134f6a2a4c1e70da5593ae        refs/tags/V2.0^{}
  • `^{}` is the syntax to *dereference* something (tag, branch) to the commit it ultimately points to. In the case of branch `abc`, `abc^{}` means "the commit which branch abc is currently pointing to" – Romain Valeri Dec 21 '21 at 14:16
  • What command did you run to get that output? The `^{}` syntax resolves an "annotated tag" to its "underlying object" (see for instance https://stackoverflow.com/questions/49283734/why-isnt-my-tag-listed-when-i-checkout-with-git-gui#49286861 and https://stackoverflow.com/questions/43858778/type-commit-in-an-annotated-tag-in-git/43859023), but I'm not sure if what you're seeing is actual duplicate tags, or two lines for each tag. – IMSoP Dec 21 '21 at 14:16
  • Looks like `0bfeb6f7` is the commit object which is referenced by the above tag object (`2191702bd`). Same for the second tag and its target commit. – Romain Valeri Dec 21 '21 at 14:19
  • 1
    @IMSoP the command was `git ls-remote --tags` – yaron samuel Dec 21 '21 at 14:52
  • @yaronsamuel See [`git help revisions`](https://git-scm.com/docs/gitrevisions#Documentation/gitrevisions.txt-emltrevgtemegemv0998em). – phd Dec 21 '21 at 14:56

1 Answers1

2

These are annotated tags.

The other type, a lightweight tag, is a name that refers to a commit. The tag itself doesn't exist as a separate object in the git repository, but it's just an alternative name for a normal commit object.

You would just have 1 line for each such tag in your listing there, something like:

1234567890c9438e2e8beda602972fdb87a73a15        refs/tags/lightweight

As a git graph you could think of something like this:

                       master
                         v
*----*----*----*----*----*
                    ^
                  v9.1

However, the presence of two lines, one of them with that ^{} syntax, means that these tags are annotated tags.

These exist as their own separate objects in the git repository and also refer to a regular commit object.

So with these two lines:

2191702bddc9438e2e8beda602972fdb87a73a15        refs/tags/V1.0
0bfeb6f7a1d2789b3e3d9944edbe680cd7355b6a        refs/tags/V1.0^{}

This means that the annotated tag object is in the object with id 2191702..., whereas that tag object refers to commit 0bfeb6f7a....

                       master
                         v
*----*----*----*----*----*
                    |
                 tag-object
                    ^
                  V1.0

TL,DR: Lightweight tags would show only the first line, the presence of the second line means these are annotated tags where the tag-name refers to an annotated tag object, and the second reference with ^{} denotes the commit the tag refers to.

Lasse V. Karlsen
  • 366,661
  • 96
  • 610
  • 798
  • Thanks for your useful answer. There is a reason to prefer annotated tags and not lightweight tags? – yaron samuel Dec 22 '21 at 13:07
  • A lightweight tag is just an alternative name for a commit. An annotated tag can have a message and will have an author and a timestamp. Annotated tags can also be signed. – Lasse V. Karlsen Dec 23 '21 at 08:36