简体   繁体   中英

How to order GitLab tags from latest to oldest

I have cloned recursively a repo from GitLab and then got the tags of the submodules by using the following command:

git submodule foreach git tag -l

So as an example. I have the following submodule (components), AccltrInterLckDet listed along with all of its tags:

Entering 'components/AccltrInterLckDet'
01.01.20210702.001
01.02.202203.001
beagledaimler.02.202211.001
legendgold.02.202210.001
octanegold.02.202210.001
titanium.02.202210.001
titanium.02.202211.001

Is there a way to order the tags from latest to oldest? As reference for that component when I go into GitLab and sort the tags by "Updated date", I get the following order:

titanium.02.202211.001 
beagledaimler.02.202211.001 
titanium.02.202210.001, legendgold.02.202210.001 
octanegold.02.202210.001 
01.02.202203.001 
01.01.20210702.001

Thanks!

You can use the taggerdate sort key to sort your tags, and add - in front to make it sort them in reverse order:

git tag --sort=-taggerdate -l

so for all your submodules, that would be

git submodule foreach git tag --sort=-taggerdate -l

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM