Git tag
排序
-
根据
refname
排序# 正序 git tag --sort=v:refname # 倒序 git tag --sort=-v:refname
$ git tag --sort=v:refname 1.0.9 2.0.0 2.0.7 4.0.8 5.0.1
-
通过
describe
获取最新的# 最新tag git describe --tags --abbrev=0 # 上一个tag git describe --tags --abbrev=0 tags/tag^
$ git describe --tags --abbrev=0 v5.4.0 $ git describe --tags --abbrev=0 tags/v5.4.0^ 5.3.8
-
通过
creatordate
排序# 正序,最近两个tag git tag -n --sort=creatordate --format="%(refname:strip=2)" | head -n 2 # 倒序, 最近两tag git tag -n --sort=-creatordate --format="%(refname:strip=2)" | head -n 2
$ git tag -n --sort=creatordate --format="%(refname:strip=2)" | head -n 2 v1.0.0 v1.0.5 $ git tag -n --sort=-creatordate --format="%(refname:strip=2)" | head -n 2 v5.4.0 5.3.8