Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

git-tag

tags

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

like image 327
still_dreaming_1 Avatar asked Mar 18 '11 22:03

still_dreaming_1


People also ask

How do I fetch all tags?

To fetch tags from your remote repository, use “git fetch” with the “–all” and the “–tags” options. Let's say for example that you have a tag named “v1. 0” that you want to check out in a branch named “release”. Using this command, you have successfully checked out the “v1.

What is git tag message?

Tags are ref's that point to specific points in Git history. Tagging is generally used to capture a point in history that is used for a marked version release (i.e. v1. 0.1). A tag is like a branch that doesn't change. Unlike branches, tags, after being created, have no further history of commits.


2 Answers

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.

like image 109
Zubair Avatar answered Oct 16 '22 10:10

Zubair


git tag -n99 

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.

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.

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.

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'

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'

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.

like image 36
still_dreaming_1 Avatar answered Oct 16 '22 10:10

still_dreaming_1