0

the question says it all. Assume you have a branch called dev but you are currently either in a detached HEAD (case of some CI/CD pipelines) or in another branch. How do you get the most recent tag for that specified branch? By recent I mean the tag attached to the latest commit. '

in How can I get the latest tag name in current branch in Git? we find ways to get the lates tag on the current branch, or the lates tag across all branches. I want the latest tag of a different branch

gota
  • 2,338
  • 4
  • 25
  • 45
  • 1
    Does this answer your question? [How can I get the latest tag name in current branch in Git?](https://stackoverflow.com/questions/1404796/how-can-i-get-the-latest-tag-name-in-current-branch-in-git) (To use with something not checked out, just specify the branch name as an argument.) – IMSoP Oct 18 '22 at 15:53
  • Can you clarify your question a bit? If you want the latest tag it shouldn't matter if you're in a detached head state or on another branch; the answer is [here](https://stackoverflow.com/questions/1404796/how-can-i-get-the-latest-tag-name-in-current-branch-in-git) (you would just pass the branch name as an argument to `git describe`). – larsks Oct 18 '22 at 15:53
  • Thank you both for taking time to reply, I appreciate. I think your comments give the extra bit of information that the linked responses do not. In my case I have 2 branches: A and B. A has many tags, B has a subset of a's tags, and the latest tag in B is not the latest tag in A. I'm in A and want to find the latest tag in B without checking out B. From your comments I see that I can use the name of the branch (B) in git describe. Note https://stackoverflow.com/a/69124985/2700173 – gota Oct 19 '22 at 09:20
  • So I don't think the question is a duplicate – gota Oct 19 '22 at 09:21

0 Answers0