Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to loop through git tags

Tags:

git

bash

svn

I did some svn to git migration. All my tags look 'strange' now:

7.18.2.0@3000
7.18.3.0@3000
7.18.4.0@3000
7.18.5.0@3000

But the tags are right. Only the name is wrong. Now I want to rename the tags.

So for every tag I want to do:

git tag new old
git tag -d old
git push origin :refs/tags/old
git push --tags

I want to script this. But I'm already stuck to find the right way how to iterate through all my tags.

How do I have to loop: for every tag do...

like image 515
DenCowboy Avatar asked May 30 '17 14:05

DenCowboy


1 Answers

what about a for loop with git tag output ?

for crt_tag in $(git tag) 
do
    # if you want to suppress @... part
    git tag ${crt_tag%@*} $crt_tag
    git tag -d $crt_tag 
    git push origin :refs/tags/$crt_tag 
    git push --tags
done
like image 191
romaric crailox Avatar answered Sep 28 '22 01:09

romaric crailox