title: Display latest tag in a commit with multiple tags
body: <p>I have a script for a large project, ten repositories, to checkout branches(local, remote, or tags) and display eventually where each is the current branch in each repository.</p>
  
  <p>I use <code>git branch</code> to display which branch or tag is checked out in the current repository. This works fine in most cases except where in the same commit there are multiple tags, resulting in printing a random tag of the ones in that commit.</p>
  
  <p>How can I fix this? Should I implement it in a different way?</p>
  
  <p>Example</p>
  
  <pre><code>for repo in ...
  do
    cd repo
    git checkout $1 || git checkout $2 || git checkout $3 ....
    git branch ##(to verify what happened)
  done
  </code></pre>
  
  <p>So lets say I run <code>./checkoutAll feat1 origin/feat1 tags/ALL7</code>
  but <code>ALL7</code> tag is in the same commit with <code>ALL6</code>, 
  <code>git branch</code> displays the <code>ALL6</code> instead of <code>ALL7</code> that I specifically asked to checkout.</p>
  
  <p>EDIT: The image below is to assist the people trying to help me,</p>
  
  <p><a href="https://i.stack.imgur.com/Jmp6x.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jmp6x.jpg" alt="enter image description here"></a></p>
  
  <p>So, let's say I run <code>git checkout tags/V9.00.00.ALL.04</code>
  then git branch displays a random tag (<code>* detached from ..</code>) of the ones that exist, 7 in this example.
  Is there a way to display the latest? or at least display the one I asked it to checkout (even if the ALL7 is the same with ALL9)?</p>