码迷,mamicode.com
首页 > 其他好文 > 详细

Show which git tag you are on?

时间:2019-12-19 09:46:42      阅读:83      评论:0      收藏:0      [点我收藏+]

标签:ret   strong   simple   over   comm   bsp   tps   solution   com   

 

git查看当前代码是在那个tag?

reference: https://stackoverflow.com/questions/3404936/show-which-git-tag-you-are-on

-----------------------------------------------------

Edit: Jakub Nar?bski has more git-fu. The following much simpler command works perfectly:

 

git describe --tags

 

(Or without the --tags if you have checked out an annotated tag. My tag is lightweight, so I need the --tags.)

 

original answer follows:

 

git describe --exact-match --tags $(git log -n1 --pretty=‘%h‘)

 

Someone with more git-fu may have a more elegant solution...

 

This leverages the fact that git-log reports the log starting from what you‘ve checked out. %h prints the abbreviated hash. Then git describe --exact-match --tags finds the tag (lightweight or annotated) that exactly matches that commit.

 

The $() syntax above assumes you‘re using bash or similar.

 

Show which git tag you are on?

标签:ret   strong   simple   over   comm   bsp   tps   solution   com   

原文地址:https://www.cnblogs.com/oxspirt/p/12064835.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!