Issue
I have the list of tags from gitlab with this commande line git tag -l.
Input :
echo listTags = $(git tag -l)
listTags= v0.0.1 v0.0.2 v0.1.0 v0.1.0-1 v0.1.0-2 v0.1.0-3 v0.1.0-4 v0.1.0-5
for tag in 'git tag -l'
do
git tag -d $tag
git push -v origin :refs/tags/$tag
done
I want to remove all the oldest pre-release version and keep the 2 latest
Output:
echo listTags = $(git tag -l)
listTags= v0.0.1 v0.0.2 v0.1.0 v0.1.0-4 v0.1.0-5
how can i resolve this problem with script shell?
Solution
git tag -l | sort -V |tail -2
This command gives you the newest 2 tags
delete all tags execpt the result from that command
Answered By - Nir Gabay
Answer Checked By - Senaida (JavaFixing Volunteer)