Print the message of a git tag

徘徊边缘 提交于 2019-12-08 17:15:30

问题


I need a git command that would output only the message of a given annotated tag. It's almost possible with git tag -ln:

$ git tag -ln v1.3.7
v1.3.7          Here be annotations

It's just that I don't want the tag and whitespace in the beginning, and throwing a regex at this feels like overkill. Is there any built-in flag i could use? I'm using git version 1.8.3.2.

Some of the answers at Print commit message of a given commit in git use git show --format=%B. I can't seem to restrict output to only the message, neither for commits or tags.


回答1:


I'm not sure what version of git this requires, but with recent versions you can also do:

git tag -l --format='%(contents)' <tag name>

to get only the tag message by itself.




回答2:


I got just the message (but the message included some extraneous stuff like PGP signature and signed-off-by lines) when I said:

git show -s --format=%B <tag>

Note the -s.



来源:https://stackoverflow.com/questions/21561789/print-the-message-of-a-git-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!