DenCowboy
DenCowboy

Reputation: 15106

How to loop through git tags

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...

Upvotes: 6

Views: 2786

Answers (1)

romaric crailox
romaric crailox

Reputation: 584

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

Upvotes: 9

Related Questions