Reputation: 1059
in my master branch I have a condition to fetch the commit id by using Tagid.Tried with git rev-parse 0.0.xx. This is giving me hash value only. Is there any way to get the current commit id based on tagid.
Upvotes: 0
Views: 201
Reputation: 30858
I missed somthing in the comment.
If 0.0.xx
is an annotated tag, which has a log message, git rev-parse 0.0.xx
returns the hash of the tag object.
To get the commit id it points to, use git rev-parse 0.0.xx^{}
instead.
If 0.0.xx
is a lightweight tag, both git rev-parse 0.0.xx
and git rev-parse 0.0.xx^{}
return the commit id.
So regardless of the type of the tag, git rev-parse <tag>^{}
always returns the commit it points to.
See gitrevisions.
Upvotes: 2