How to get the branch from tag name in Git?

前端 未结 3 1855
栀梦
栀梦 2021-01-19 16:51

I am trying to get the branch name from a given tag. I tried git describe --tag but this doesn\'t provide me any branch name. I tried using

3条回答
  •  别那么骄傲
    2021-01-19 17:21

    If you know the commit number the tag is linked to, you can find the branch from which the tag was placed from this command:

    git_branch=$(git for-each-ref | grep ${commit_num} | grep origin | sed "s/.*\///")
    

提交回复
热议问题