title: Git: How to determine if a ref to a commit exists
body: <p>I need to find out if a ref to a commit exists. One thing that almost works is <code>git show</code> which sometimes returns non-zero if the ref does not exist. However, it also accepts paths within the current source tree. So if I have a file named <code>master</code> but the ref <code>master</code> does not exist, <code>git show</code> succeeds. I have not been able to find any more specific commands.</p>
  
  <p>I would like the method to accept:</p>
  
  <ul>
  <li>Names of branches</li>
  <li>Commit hashes</li>
  <li>Tags</li>
  <li>Keywords like HEAD</li>
  </ul>
  
  <p>Edit: I'm doing this because I want to preform sanity checks on user input programatically.</p>