好好爱自己!

Show which git tag you are on?

 

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.

 

posted @   立志做一个好的程序员  阅读(328)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
历史上的今天:
2018-12-19 php -- 取路径:getcwd()、__DIR__、__FILE__ 的区别
2017-12-19 串口工具
2016-12-19 md5sum

不断学习创作,与自己快乐相处

点击右上角即可分享
微信分享提示