4

The git tag documentation says that you can tag either a commit or an object:

<commit>
<object>
The object that the new tag will refer to, usually a commit. Defaults to HEAD.

And indeed you can take the hash of a blob object and tag it. But I don't understand - what is it good for? what can you do with this tag?

YoavKlein
  • 2,005
  • 9
  • 38
  • I think there is some misunderstanding here, once you tag a commit or SHA it creates a tag object. Tag's are essentially read-only "branches" used normally as milestones since they are often more friendly than a SHA. E.g either named v1.0 etc or any name you like which is easier to remember once something worked and is often what is used to release a product. – Mark Aug 01 '21 at 21:30
  • 5
    You can tag anything to give thing a name and to prevent garbage collector to remove unreferenced objects. For example, I store my GPG public key (to verify my signed commits/tags) as a blob and [tag the blob](https://git.phdru.name/?p=git-scripts.git;a=blob;f=add-pubkey/add-pubkey-blob-tag). – phd Aug 01 '21 at 21:34
  • @phd Cool, you should give that as an answer. – matt Aug 01 '21 at 23:42

1 Answers1

6

You can tag anything to give thing a name instead of a long cryptic ID and to prevent garbage collector to remove unreferenced objects.

For example, I store my GPG public key (to verify my signed commits/tags) as a blob and tag the blob (the technics is described in Git Book, chapter Git Internals - Git References).

phd
  • 82,685
  • 13
  • 120
  • 165