tags:

views:

25

answers:

1

Here is the man page for git show-ref -d . They also have an example at the bottom. Still I am not able to understand what dereference does?

+3  A: 

In git, a "normal" (annotated, not lightweight) tag is an object unto itself, containing metadata and the SHA1 of the object it tags. There's a pretty picture in the section of the git community book on the git object model (scroll to the bottom).

So, when you use show-ref on a normal tag, it will normally give you information about the tag object. With the -d/--dereference option, it will dereference the tag into the object the tag refers to, and provide information about it instead.

And a note on lightweight vs. annotated tags, in case you aren't aware of that: a lightweight tag is created by using git tag <tag name> (i.e. without any of the metadata-providing options like -a, -s, or -u). It's not a tag object at all, just a ref pointing straight to the object you've tagged. If you provide one of those options, you're attaching metadata to the tag, so git creates a tag object to hold that.

Jefromi
Good summary.+1 See also http://stackoverflow.com/questions/1194385/seeing-what-revision-goes-with-a-tag-in-git: "if you don't know/care whether the tag is a tag object or a lightweight label but want to see just the commit you can use `git show v1.5.0^{}`, or `git rev-parse v1.5.0^{}` for a scriptable way to retrieve the commit id."
VonC
VonC's helpful hint probably looks a bit odd to anyone not very familiar with git. The `^{}` suffix is a special notation for tags; it means "dereference the tag repeatedly until you find something besides a tag" - just in case you've done something crazy like tag a tag with a tag.
Jefromi
@Jefromi: true, the notation is odd ;) As for tagging a tag with a tag, one can imagine it could help to add some kind of metadata (like for instance a "promotion level" 'rejected', 'tested', 'released', ...) to an existing tagged commit.
VonC