How to get the latest tag name in current branch in Git?

前端 未结 24 2393
你的背包
你的背包 2020-11-22 17:04

What\'s the simplest way to get the most recent tag in Git?

git tag a HEAD
git tag b HEAD^^
git tag c HEAD^
git tag

output:



        
24条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 17:32

    For the question as asked,

    How to get the latest tag name in the current branch

    you want

    git log --first-parent --pretty=%d | grep -m1 tag:
    

    --first-parent tells git log not to detail any merged histories, --pretty=%d says to show only the decorations i.e. local names for any commits. grep -m1 says "match just one", so you get just the most-recent tag.

提交回复
热议问题