Git Tag list, display commit sha1 hashes

后端 未结 8 1137
无人共我
无人共我 2020-12-12 17:56

so the git tag command lists the current git tags

tag1
tag2

git tag -n prints tag\'s message

tag1         


        
8条回答
  •  南笙
    南笙 (楼主)
    2020-12-12 18:18

    The git tag command is underdeveloped. A lot is desired but missing in it, like full tag details and tags in the commit history order.

    I like this instead, which gives exactly what I want but can't get from git tag:

    git log --oneline --decorate --tags --no-walk
    

    This gives a very nice color-coded view of the tags in the reverse chronological order (as it would be in the full log). That way, not only do you see the tags, you will also see the abbreviated hashes and the commit messages of the tag commits.


    I have aliased it to git t and git tags as follows:

    git config --global alias.tags "log --oneline --decorate --tags --no-walk"
    git config --global alias.t "!git tags"
    

    Note: I had to use bash redirection for git t as Git doesn't support calling an alias from another alias (which is a bummer).


    If you want to see the commit date and time, try:

    git log --tags --no-walk --date=iso-local --pretty='%C(auto)%h %cd%d %s'
    

    You can use other date formats in the --date option as well as fully control the output to match your unique taste in the --pretty option. Both options are well-documented in the git-log Documentation.

提交回复
热议问题