I have a script for a large project, ten repositories, for checking branches (local, remote or tags) and displaying ultimately where each of them is the current branch in each repository.
I use git branch to display which branch or tag is unloaded in the current repository. This works fine in most cases, unless there are several tags in the same commit, which results in printing a random tag from the ones in this commit.
How can i fix this? Should I implement it differently?
Example
for repo in ... do cd repo git checkout $1 || git checkout $2 || git checkout $3 .... git branch
So let's say I ran ./checkoutAll feat1 origin/feat1 tags/ALL7 but the ALL7 tag is in the same commit with ALL6 , git branch displays ALL6 instead of ALL7 , which I specifically asked to check.
EDIT: the image below will help people who are trying to help me,

So, let's say I ran git checkout tags/V9.00.00.ALL.04 then the git branch displays a random tag ( * detached from .. ) of those that exist, 7 in this example. Is there a way to show the latest data? or at least display the one I asked to check (even if ALL7 is the same as ALL9)?
source share