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?
Typing "git tag" without arguments, also lists all tags. Sort in a specific order.
JB. JB. Returns the latest tag in the current branch. To get the latest annotated tag which targets only the current commit in the current branch, use git describe --exact-match --abbrev=0 .
View tags for a repository (console)In Repositories, choose the name of the repository where you want to view tags. In the navigation pane, choose Settings. Choose Repository tags.
Do you use linux? If so you can use this command
git ls-remote --tags | grep -o 'refs/tags/dev-[0-9]*\.[0-9]*\.[0-9]*' | sort -r | head | grep -o '[^\/]*$'
It will show you 10 latest tags (with name dev-x.y.z)
UPD
You can use this bash script to get latest tags:
#!/bin/bash TAGS=("dev-[0-9]*\.[0-9]*\.[0-9]*" "test-[0-9]*\.[0-9]*\.[0-9]*" "good-[0-9]*" "new [0-9][0-9][0-9]") for index in ${!TAGS[*]} do git ls-remote --tags | grep -o "refs/tags/${TAGS[$index]}" | sort -rV | head | grep -o '[^\/]*$' done
Just add in array TAGS regular expressions that you want, and you'll get 10 latest tags for every of them. If you want to get more or less tags, just add param -n to head command 'head -n 5' or 'head -n 15'.
Just in case. Save it in folder ~/bin (for example with name git_tags), then add executable permission (chmod +x git_tags), this will allow you to run this bash script from every place (just type git_tags).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With