Psychozoic Psychozoic - 1 year ago 88
Git Question

How to get list of latest tags in remote git?

There are alot of methods to get latest tags when you have local git repo.

But i want to get list of latest tags on remote repo.

I know about "git ls-remote", and everything is fine when you use tags like x.y.z (where x,y,z are numbers).
But when tags looks like "test-x.y.z" and "dev-x.y.z" i noticed that large amount of "test" tags will pull out any new "dev" tags, which is not correct.

So, how would you like solve this?

Answer Source

some guy told me that command:

git ls-remote -t repo.url.git | awk '{print $2}' | cut -d '/' -f 3 | cut -d '^' -f 1  | sort -b -t . -k 1,1nr -k 2,2nr -k 3,3r -k 4,4r -k 5,5r | uniq

and this is not the best solution, but he opened my eyes on command sort.

but i would like to know other versions.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download