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 laborious to me.
Update
I realized 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.
Even though this is pretty old, I thought I would point out a cool feature I just found for listing tags with commits:
It will show the branches which end/start at a commit, and the tags for commits.
From git mailing list, here is the way to get the list of commit hashes for tags with automatic dereferencing for annotated tags:
For example,
git show-ref --abbrev=7 --tags
will show you something like the following:i'd also like to know the right way, but you can always peek either into:
or:
So I have a load of release folders, where those folders may be checked out from one of a few different repos, and may be dev, qa or master branches or may be production releases, checked out from a tag, and the tag may be annotated or not. I have a script that will look at the target folder and get be back an answer in the form -. The problem is different versions of git return different status' for a tag checkout.
So I found
git show-ref --tags
worked initially, except for the annotated tags. However adding -d added a separate entry to the list of tags, one for the tag, the other for the annotation (the annotation commit was identified as ^{} which I stripped out with sed).So this is the core of my script, for anyone that wants it:-
Use
(which would return SHA-1 of a commit even for annotated tag).
git show-ref <tag>
would also work if<tag>
is not annotated. And there is alwaysgit for-each-ref
(see documentation for details).