Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is dereference in the context of git show-ref -d

Tags:

git

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?

like image 264
Nick Vanderbilt Avatar asked Mar 28 '10 22:03

Nick Vanderbilt


1 Answers

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.

like image 190
Cascabel Avatar answered Oct 27 '22 00:10

Cascabel