Home > Software design >  How to order GitLab tags from latest to oldest
How to order GitLab tags from latest to oldest

Time:12-22

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!

CodePudding user response:

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
  • Related