How to list all tags along with the full message in git?

核能气质少年 提交于 2019-11-27 19:41:22

问题


I want git to list all tags along with the full annotation or commit message. Something like this is close:

git tag -n5

This does exactly what I want except that it will only show up to the first 5 lines of the tag message.

I guess I can just use a very large number. What is the highest number I can use here? Is it the same on every computer?

UPDATE: I have had much time to think about this, and now I think I don't necessarily want to show the entire message if it is extraordinarily long. Something like this seems to work fine for me:

git tag -n99

If the tag message is really longer than 99 lines, I don't want to see all of it. But Git is extremely complex and flexible. In what cases would this not be the best solution? I noticed many of the posted solutions used the -l otion, but isn't that just for specifying a pattern to search for?


回答1:


Try this it will list all the tags along with annotations & 9 lines of message for every tag:

git tag -n9

can also use

git tag -l -n9

if specific tags are to list:

git tag -l -n9 v3.*

(e.g, above command will only display tags starting with "v3.")

-l , --list List tags with names that match the given pattern (or all if no pattern is given). Running "git tag" without arguments also lists all tags. The pattern is a shell wildcard (i.e., matched using fnmatch(3)). Multiple patterns may be given; if any of them matches, the tag is shown.




回答2:


git tag -n99

Short and sweet. This will list up to 99 lines from the annotation/commit message. Here is a link to the official documentation for git tag: http://git-scm.com/docs/git-tag




回答3:


Mark Longair's answer (using git show) is close to what is desired in the question. However, it also includes the commit pointed at by the tag, along with the full patch for that commit. Since the commit can be somewhat unrelated to the tag (it's only one commit that the tag is attempting to capture), this may be undesirable. I believe the following is a bit nicer:

for t in `git tag -l`; do git cat-file -p `git rev-parse $t`; done



回答4:


It's far from pretty, but you could create a script or an alias that does something like this:

for c in $(git for-each-ref refs/tags/ --format='%(refname)'); do echo $c; git show --quiet "$c"; echo; done



回答5:


Last tag message only:

git cat-file -p $(git rev-parse $(git tag -l | tail -n1)) | tail -n +6



回答6:


I prefer doing this on the command line, but if you don't mind a web interface and you use GitHub, you can visit https://github.com/user/repo/tags and click on the "..." next to each tag to display its annotation.



来源:https://stackoverflow.com/questions/5358336/how-to-list-all-tags-along-with-the-full-message-in-git

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