title: How to check if tag exists in if/else
body: <p>How can I check if a tag exists in my GIT repo.
  I get as input some tagname and I have to check if it's a valid tag with a <code>if else statement.</code>
  TAG="tagname"</p>
  
  <p>I tried:</p>
  
  <pre><code>if [ git rev-parse ${TAG} &gt;/dev/null 2&gt;&amp;1 ]; then
    echo "tag exists";
  else
    echo "tag does not exist";
  </code></pre>
  
  <p>But it didn't work</p>