show all tags in git log

前端 未结 3 1488
一生所求
一生所求 2021-01-30 11:59

Why does git log --decorate not display more than one tag per commit?

EDIT: Charles Bailey has come up with the answer (at

3条回答
  •  不要未来只要你来
    2021-01-30 12:53

    Note about tag of tag (tagging a tag), which is at the origin of your issue, as Charles Bailey correctly pointed out in the comment:

    Make sure you study this thread, as overriding a signed tag is not as easy:

    • if you already pushed a tag, the git tag man page seriously advised against a simple git tag -f B to replace a tag name "A"
    • don't try to recreate a signed tag with git tag -f (see the thread extract below)

      (it is about a corner case, but quite instructive about tags in general, and it comes from another SO contributor Jakub Narębski):

    Please note that the name of tag (heavyweight tag, i.e. tag object) is stored in two places:

    • in the tag object itself as a contents of 'tag' header (you can see it in output of "git show " and also in output of "git cat-file -p ", where is heavyweight tag, e.g. v1.6.3 in git.git repository),
    • and also is default name of tag reference (reference in "refs/tags/*" namespace) pointing to a tag object.
      Note that the tag reference (appropriate reference in the "refs/tags/*" namespace) is purely local matter; what one repository has in 'refs/tags/v0.1.3', other can have in 'refs/tags/sub/v0.1.3' for example.

    So when you create signed tag 'A', you have the following situation (assuming that it points at some commit)

      35805ce   <--- 5b7b4ead  <=== refs/tags/A
      (commit)       tag A
                     (tag)
    

    Please also note that "git tag -f A A" (notice the absence of options forcing it to be an annotated tag) is a noop - it doesn't change the situation.

    If you do "git tag -f -s A A": note that you force owerwriting a tag (so git assumes that you know what you are doing), and that one of -s / -a / -m options is used to force annotated tag (creation of tag object), you will get the following situation

      35805ce   <--- 5b7b4ea  <--- ada8ddc  <=== refs/tags/A
      (commit)       tag A         tag A
                     (tag)         (tag)
    

    Note also that "git show A" would show the whole chain down to the non-tag object...

提交回复
热议问题