如何在 git 中列出所有标签以及完整消息? [英] How to list all tags along with the full message in git?

查看:16
本文介绍了如何在 git 中列出所有标签以及完整消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望 git 列出所有标签以及完整的注释或提交消息.这样的事情很接近:

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

git tag -n5

这正是我想要的,只是它只会显示标签消息的前 5 行.

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 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.

推荐答案

git tag -n99

短而甜.这将列出来自每个标签注释/提交消息的多达 99 行.这里是 git tag 官方文档的链接.

Short and sweet. This will list up to 99 lines from each tag annotation/commit message. Here is a link to the official documentation for git tag.

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

I now think the limitation of only showing up to 99 lines per tag is actually a good thing as most of the time, if there were really more than 99 lines for a single tag, you wouldn't really want to see all the rest of the lines would you? If you did want to see more than 99 lines per tag, you could always increase this to a larger number.

我的意思是,我想可能有特定的情况或原因希望看到大量标签消息,但您在什么时候希望看到整个消息?当它有超过 999 行时?10,000?1,000,000?我的观点是,通常对您将看到的行数设置一个上限是有意义的,并且这个数字允许您设置它.

I mean, I guess there could be a specific situation or reason to want to see massive tag messages, but at what point do you not want to see the whole message? When it has more than 999 lines? 10,000? 1,000,000? My point is, it typically makes sense to have a cap on how many lines you would see, and this number allows you to set that.

由于我正在为您在查看标签时通常希望看到的内容进行论证,因此将这样的内容设置为别名可能是有意义的(来自 Iulian Onofrei 的以下评论):

Since I am making an argument for what you generally want to see when looking at your tags, it probably makes sense to set something like this as an alias (from Iulian Onofrei's comment below):

git config --global alias.tags 'tag -n99'

我的意思是,你真的不想在每次只想查看标签时都输入 git tag -n99 吗?配置好别名后,只要您想查看标签,只需在终端中输入 git tags 即可.就个人而言,我更喜欢比这更进一步,为我所有常用的命令创建更缩写的 bash 别名.为此,您可以在 .bashrc 文件中添加类似这样的内容(适用于 Linux 和类似环境):

I mean, you don't really want to have to type in git tag -n99 every time you just want to see your tags do you? Once that alias is configured, whenever you want to see your tags, you would just type git tags into your terminal. Personally, I prefer to take things a step further than this and create even more abbreviated bash aliases for all my commonly used commands. For that purpose, you could add something like this to your .bashrc file (works on Linux and similar environments):

alias gtag='git tag -n99'

然后,只要您想查看您的标签,您只需输入 gtag.沿着别名路径(git aliases 或 bash aliases 或其他)的另一个优点是您现在已经有了一个位置,您可以在其中添加进一步的自定义,以您个人的方式,通常希望您的标签显示给您(例如排序它们以某些方式,如我在下面的评论等).一旦你克服了创建你的第一个别名的麻烦,你现在就会意识到为你喜欢以自定义方式工作的其他事情创建更多别名是多么容易,比如 git log,但是让我们将其保存为不同的问题/答案.

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 中列出所有标签以及完整消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆