title: Get git current branch/tag name
body: <p>How can I get the current branch or tag name for my working copy?  I have seen references that indicate <code>rev-parse --abbrev-ref HEAD</code> will give branch name, but this doesn't work if the checkout is of a tag, in which case it just returns 'HEAD'. I need to somehow get the tag name of these revisions.</p>
  
  <p>To be clear, I want one of two possible names:</p>
  
  <ol>
  <li>If the current checkout is the HEAD of a branch, I want the branch name</li>
  <li>If it is a detached HEAD, I want the tag name (on the assumption there is a tag)</li>
  </ol>