title: How to programmatically determine whether the Git checkout is a tag and if so, what is the tag name
body: <p>In a Unix or GNU scripting environment (e.g. a Linux distro, Cygwin, OSX), what is the best way to determine whether the current checkout is a Git tag. If it is a tag, how can I determine the tag name?</p>
  
  <p>One use of this technique would be automatically labeling a release (like <code>svnversion</code> would do with Subversion).</p>
  
  <p>See my related question about <a href="https://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch">programmatically detecting the Git branch</a>.</p>