Wednesday, October 13, 2010

Git: What SHA does this tag refer to?

I often have to tag a branch in my Git repo for QA. Our QA people prefer to have a tag to deploy on to their QA environments, so that they do not have a "moving target" to ensure features and bugs are accounted for. Sometimes, however, I forget exactly where in the lineage the tag was created. In other words, on which commit the tag was drawn.

There is a way in Git to see this information. Here is a use case for the situation.

You complete feature A and commit it. You then tag feature A with an annotated tag and immediately start working on feature B, then C, etc. QA asks about the tag. You no longer remember what that tag was for, so you fire up a console and type in the following to find out:

git show-ref --dereference


You can find the tag in the list and perform a simple git log matching the sha from the show-ref to the sha in the git log. Simple. Even easier would be to run a filter using --exclude-existing on the show-ref using a regular expression and then piping the result to git show or git log.

1 comment:

Jason Noble said...

Wouldn't " git log --oneline v9.0.8..v9.0.9" be better to show you what changed between tags?