我想要git列出所有标签连同完整的注释或提交消息。类似这样的事情很接近:

git tag -n5

这完全是我想要的,除了它只会显示标签消息的前5行。

我想我可以用一个很大的数。这里最大的数是多少?每台电脑都一样吗?

UPDATE: I have had much time to think about this, and now I think I don't necessarily want to show the entirety of each message if some of them are extraordinarily long. I didn't really have any particular need that required me to see massive messages (other than my own propensity to be long winded in everything I write, including tag messages). I just didn't like the idea that it was not necessarily going to show me the whole message, as that made me feel like it was hiding information from me. But too much information can also be a bad thing.


当前回答

我更喜欢在命令行上做这件事,但如果你不介意web界面,并且你使用GitHub,你可以访问https://github.com/user/repo/tags,然后点击每个标签旁边的“…”来显示它的注释。

其他回答

使用——format选项

git tag -l --format='%(tag) %(subject)'
git tag -n99

又短又甜。这将从每个标记注释/提交消息中列出最多99行。这里是git标签官方文档的链接。

我现在认为限制每个标签最多显示99行实际上是一件好事,因为大多数时候,如果一个标签有超过99行,你不会真的想看到所有剩下的行,对吗?如果您确实希望每个标记的行数超过99行,则可以将其增加到更大的数字。

我的意思是,我猜可能有特定的情况或原因想要看到大量的标记消息,但在什么情况下您不想看到整个消息?当它有超过999行?10000年?1000000年?我的观点是,对你能看到的行数设置一个上限通常是有意义的,这个数字允许你设置它。

因为我正在为你在查看标签时通常想要看到的内容做一个论证,所以将这样的东西设置为别名可能是有意义的(来自下面Iulian Onofrei的评论):

Git配置——全局别名。标签'tag -n99'

我的意思是,你不想每次都输入gittag -n99你只是想看到你的标签,对吧?一旦配置了别名,无论何时你想看到你的标记,你只需要在你的终端中输入git标记。就我个人而言,我更喜欢更进一步,为我所有常用的命令创建更简短的bash别名。为此,你可以在你的.bashrc文件中添加这样的东西(适用于Linux和类似的环境):

别名 gtag='git tag -n99'

Then whenever you want to see your tags, you just type gtag. Another advantage of going down the alias path (either git aliases or bash aliases or whatever) is you now have a spot already in place where you can add further customizations to how you personally, generally want to have your tags shown to you (like sorting them in certain ways as in my comment below, etc). Once you get over the hurtle of creating your first alias, you will now realize how easy it is to create more of them for other things you like to work in a customized way, like git log, but let's save that one for a different question/answer.

仅限最后标签信息:

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

我更喜欢在命令行上做这件事,但如果你不介意web界面,并且你使用GitHub,你可以访问https://github.com/user/repo/tags,然后点击每个标签旁边的“…”来显示它的注释。

使用此命令可以显示标签的消息

git tag -n

-n选项用于显示消息。