I have a bunch of unannotated tags in the repository and I want to work out which commit they point to. Is there a command that that will just list the tags and their commit SHAs? Checking out the tag and looking at the HEAD seems a bit too labourious to me.
Edit: I realised after I went through the responses that what I actually wanted was to simply look at the history leading up to the tag, for which git log <tagname>
is sufficient.
The answer that is marked as answer is useful for getting a list of tags and their commits, which is what I asked. With a bit of shell hackery i'm sure it's possible to transform those into SHA+Commit message.
Summary: Since there are about 4 almost equally acceptable yet different answers I will summarise all the different ways to skin a tag.
git rev-list $TAG | head -n 1
(thanks mipadi).git rev-list
outputs the commits that lead up to the$TAG
similar togit log
but only showing the SHA1 of the commit. For non-unix heads like myselfhead -n 1
will show the first line of the output, which is the tip of the tag.git show-ref --tags
(thanks Charles Bailey) will show all tags (local and fetched from remote) and their SHA1s.git show-ref $TAG
(thanks Jakub Narębski) will show the tag and its path along with the SHA1.git rev-parse $TAG
(thanks Jakub Narębski) will show the SHA1 of an unannotated tag.git rev-parse --verify $TAG^{commit}
(thanks Jakub Narębski) will show a SHA1 of both annotated and unannotated tags. On Windows usegit rev-parse --verify %TAG%^^^^{commit}
(four hats).cat .git/refs/tags/*
orcat .git/packed-refs
(thanks The MYYN) depending on whether or not the tag is local or fetched from remote.