Get the time and date of git tags

后端 未结 7 1376
逝去的感伤
逝去的感伤 2021-01-30 15:37

I have a project that is using git and have tagged all the releases with a tag.

$ git tag
v1.0.0
v1.0.1
v1.0.2
v1.0.3
v1.1.0

My goal is to list

7条回答
  •  轮回少年
    2021-01-30 16:15

    All of the answers here are great and in the proper git style. But I needed a tag, its date and its message and only the last 10 tags. So I just did it in a very pedestrian way. But save it as a shell function or script and it becomes a one-liner.

    for ver in `git tag | tail -10`; do
        DATE=`git log -1 --format=%ai $ver | awk '{print $1}'`
        MESSAGE=`git tag -n $ver | cat | awk '{a=match($0, $2); print substr($0,a)}'`
        echo "$ver \t| $DATE | $MESSAGE"
    done
    

提交回复
热议问题