Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete multiple git remote tags and push once

Tags:

git

tags

In Git, how can I delete multiple tags before pushing?

I know how to do it with one tag at a time. Not sure if it's possible to do multiple.

like image 211
KanwarG Avatar asked Aug 22 '17 13:08

KanwarG


People also ask

Can you delete tags in git?

Use Git to delete a Git tag To delete the Git tag from the local repo, run the git tag -d tag-name command where tag-name is the name of the Git tag you want to delete.

Does git push push all tags?

By default, git push will not push tags. Tags have to be explicitly passed to git push . To push multiple tags simultaneously pass the --tags option to git push command.


2 Answers

To delete locally multiple tags: git tag:

git tag -d <tagname>...

So simply:

git tag -d TAG1 TAG2 TAG3 

To delete multiple tags remotely: git push:

git push [-d | --delete] [<repository> [<refspec>...]]

So simply:

git push ${REMOTE_NAME:-origin} --delete TAG1 TAG2 TAG3 

TL;DR:

git tag -d TAG1 TAG2 TAG3 git push origin -d TAG1 TAG2 TAG3 
like image 64
zigarn Avatar answered Sep 18 '22 13:09

zigarn


It will delete all matching tag patterns.

//Delete remote: git push -d origin $(git tag -l "tag_prefix*")  // Delete local: git tag -d $(git tag -l "tag_prefix*")  // Examples: git tag -d $(git tag -l "v1.0*") git push -d origin $(git tag -l "*v3.[2]*-beta*") 
like image 36
AechoLiu Avatar answered Sep 19 '22 13:09

AechoLiu