Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@gabrielfern

This comment has been minimized.

Copy link

gabrielfern commented Jul 27, 2017

thanks for the indirect help

@Jonathan-Rosewood

This comment has been minimized.

Copy link

Jonathan-Rosewood commented Aug 11, 2017

Yep, thanks

@Dianna

This comment has been minimized.

Copy link

Dianna commented Aug 15, 2017

Thanks!

@alexismaster

This comment has been minimized.

Copy link

alexismaster commented Sep 21, 2017

Thanks!

@arturmamedov

This comment has been minimized.

Copy link

arturmamedov commented Sep 27, 2017

Thank you man!

@shrishty

This comment has been minimized.

Copy link

shrishty commented Oct 4, 2017

Thanks

@konekoya

This comment has been minimized.

Copy link

konekoya commented Oct 12, 2017

Thanks for sharing this πŸ’―

@natec8

This comment has been minimized.

Copy link

natec8 commented Oct 13, 2017

Thanks

@jamjon3

This comment has been minimized.

Copy link

jamjon3 commented Oct 30, 2017

Thanks!

@iberck

This comment has been minimized.

Copy link

iberck commented Nov 8, 2017

Thanks

@andfoy

This comment has been minimized.

Copy link

andfoy commented Nov 20, 2017

Thanks!

@Chrispassold

This comment has been minimized.

Copy link

Chrispassold commented Nov 23, 2017

Thanks!

@Campano

This comment has been minimized.

Copy link

Campano commented Nov 28, 2017

+1

@vishalvijay

This comment has been minimized.

Copy link

vishalvijay commented Nov 29, 2017

+1

@EvgenyUnvsoft

This comment has been minimized.

Copy link

EvgenyUnvsoft commented Nov 30, 2017

thanks!

@arecvlohe

This comment has been minimized.

Copy link

arecvlohe commented Dec 13, 2017

Thanks!

@DoNotSpamPls

This comment has been minimized.

Copy link

DoNotSpamPls commented Dec 25, 2017

Thanks!

@PhaserEditor2D

This comment has been minimized.

Copy link

PhaserEditor2D commented Dec 28, 2017

+1

@Firecul

This comment has been minimized.

Copy link

Firecul commented Jan 1, 2018

Thank you

@paxperscientiam

This comment has been minimized.

Copy link

paxperscientiam commented Jan 4, 2018

Here is an alias of this sweet, sweet gist.

Usage: git tag-be-gone <remote> <tag1> [tag2 tag3 tagN]

tag-be-gone = "!f() { local r=\"${1}\" ; shift ; git tag -d \"${@}\" && \
                              git push --delete \"${r}\"  \"${@}\" ; \
                            } ; f";
@MRodSebastian

This comment has been minimized.

Copy link

MRodSebastian commented Jan 26, 2018

Thanks!

@jockerxlj

This comment has been minimized.

Copy link

jockerxlj commented Jan 30, 2018

Thanks!

@BradleyA

This comment has been minimized.

Copy link

BradleyA commented Feb 7, 2018

thanks!

@joh-klein

This comment has been minimized.

Copy link

joh-klein commented Feb 7, 2018

Thanks!
I had to delete a lot of tags wich were very similar (i.e. 2.0.0-1, 2.0.0-2, 2.0.0-3), so this is what I did:

git tag --list '2.0.0-*' | xargs -I % echo "git tag -d %; git push --delete origin %" | sh

@hendisantika

This comment has been minimized.

Copy link

hendisantika commented Feb 7, 2018

Nice.
Thanks

@msta

This comment has been minimized.

Copy link

msta commented Feb 8, 2018

Thanks

@gtdeng

This comment has been minimized.

Copy link

gtdeng commented Feb 16, 2018

Thanks! Tho oddly git push origin :refs/tags/12345 renamed my repo on github, so I'm using git push origin :[tag] to delete a remote branch instead. It's shorter and easier to remember.

@hamedtaha

This comment has been minimized.

Copy link

hamedtaha commented Feb 27, 2018

πŸ’― Thanks πŸ‘

@matiasa18

This comment has been minimized.

Copy link

matiasa18 commented Mar 1, 2018

Thank you, worked like a charm!

@TimRChen

This comment has been minimized.

Copy link

TimRChen commented Mar 16, 2018

Thanks!

@Chamuth

This comment has been minimized.

Copy link

Chamuth commented Mar 19, 2018

Thank you very much

@joshhunt

This comment has been minimized.

Copy link

joshhunt commented Mar 20, 2018

Thanks!

@liranfar

This comment has been minimized.

Copy link

liranfar commented Mar 22, 2018

Thanks a lot! πŸ₯‡

@petrewoo

This comment has been minimized.

Copy link

petrewoo commented Mar 23, 2018

Thx!

@DenisK2017

This comment has been minimized.

Copy link

DenisK2017 commented Apr 2, 2018

Thank you very much!

@AlexanderTserkovniy

This comment has been minimized.

Copy link

AlexanderTserkovniy commented Apr 16, 2018

Thanks!

@annisuu

This comment has been minimized.

Copy link

annisuu commented Apr 16, 2018

THANKS!

@devmike01

This comment has been minimized.

Copy link

devmike01 commented Apr 25, 2018

Thank you.

@astrieanna

This comment has been minimized.

Copy link

astrieanna commented Apr 30, 2018

Thank you πŸ‘

@castor55

This comment has been minimized.

Copy link

castor55 commented May 2, 2018

Thank you.

@Budyn

This comment has been minimized.

Copy link

Budyn commented May 15, 2018

Thanks

@Erkin97

This comment has been minimized.

Copy link

Erkin97 commented May 18, 2018

thanks :)

@fuchao2012

This comment has been minimized.

Copy link

fuchao2012 commented May 21, 2018

thanks @paxperscientiam @joh-klein

git alias config steps

$ vi ~/.gitconfig
  • add git alias into alias scope, if dont have [alias], you need add by yourself
[alias]
        remove-tags = "!f() { git tag -l ${1} | xargs -I % echo \"git tag -d % && git push --delete origin %\" | sh; }; f"
  • run git alias, add regexp to match tags to delete
git remove-tags <regexp>
  • if you do not know which regexp is work, recommend use list first
git tag --list

DEMO

$ git tag -a 'v10.0.0'
$ git remove-tags 'v10.0.*'
$ git tag -l
@jrodas19

This comment has been minimized.

Copy link

jrodas19 commented Jun 5, 2018

gracias!

@kansalaman

This comment has been minimized.

Copy link

kansalaman commented Jun 6, 2018

Thanks!!

@jv-oliveira

This comment has been minimized.

Copy link

jv-oliveira commented Jun 7, 2018

thank you!

@apmason

This comment has been minimized.

Copy link

apmason commented Jun 8, 2018

Thanks!

@Smosker

This comment has been minimized.

Copy link

Smosker commented Jun 11, 2018

thanks!

@isaac-weisberg

This comment has been minimized.

Copy link

isaac-weisberg commented Jun 12, 2018

Thank you very much, appreciate it.

@LanguidSquid

This comment has been minimized.

Copy link

LanguidSquid commented Jun 14, 2018

Thanks, good looking out fam

@itschmp

This comment has been minimized.

Copy link

itschmp commented Jun 21, 2018

Many thanks. Nice approach to help dear fellows developers.

@Maksio

This comment has been minimized.

Copy link

Maksio commented Jun 25, 2018

thank you very much!

@martiis

This comment has been minimized.

Copy link

martiis commented Jun 28, 2018

Very nais, thank you :D

@heknt

This comment has been minimized.

Copy link

heknt commented Jun 30, 2018

Thanks, really helped me!

@colinwilson

This comment has been minimized.

Copy link

colinwilson commented Jul 2, 2018

Thank you. πŸ‘

@Erkin97

This comment has been minimized.

Copy link

Erkin97 commented Jul 4, 2018

thanks

@giovaninppc

This comment has been minimized.

Copy link

giovaninppc commented Jul 5, 2018

Thanks!

@ihsoft

This comment has been minimized.

Copy link

ihsoft commented Jul 17, 2018

Awesome! Thanks.

@JervyShi

This comment has been minimized.

Copy link

JervyShi commented Jul 17, 2018

Thanks!

@Bijan-Ghasemi-Afshar

This comment has been minimized.

Copy link

Bijan-Ghasemi-Afshar commented Jul 18, 2018

Thanks!

@gvdm90

This comment has been minimized.

Copy link

gvdm90 commented Jul 19, 2018

Thanks!

@henriquellemos

This comment has been minimized.

Copy link

henriquellemos commented Jul 20, 2018

Thanks!

@roberGzt

This comment has been minimized.

Copy link

roberGzt commented Aug 1, 2018

Thanks!

@ivolivares

This comment has been minimized.

Copy link

ivolivares commented Aug 1, 2018

Thanks!

@maynalysa

This comment has been minimized.

Copy link

maynalysa commented Aug 3, 2018

Thanks !

@marceloalejoc

This comment has been minimized.

Copy link

marceloalejoc commented Aug 3, 2018

Thanks! +1

@Wizzzo

This comment has been minimized.

Copy link

Wizzzo commented Aug 5, 2018

Great!
Thanks

@splait

This comment has been minimized.

Copy link

splait commented Aug 8, 2018

Thanks

@NSMyself

This comment has been minimized.

Copy link

NSMyself commented Aug 9, 2018

Thanks!

@werbth

This comment has been minimized.

Copy link

werbth commented Aug 11, 2018

Thanks!

@CSaratakij

This comment has been minimized.

Copy link

CSaratakij commented Aug 19, 2018

πŸ‘

@ghost

This comment has been minimized.

Copy link

ghost commented Aug 21, 2018

Thanks

@noamhacker

This comment has been minimized.

Copy link

noamhacker commented Sep 20, 2018

Thanks!

@lamg

This comment has been minimized.

Copy link

lamg commented Sep 26, 2018

Thanks!!

@lemon-clown

This comment has been minimized.

Copy link

lemon-clown commented Oct 4, 2018

Thanks!

@WilliamPourmajidi

This comment has been minimized.

Copy link

WilliamPourmajidi commented Oct 9, 2018

Thanks! Worked fine.

In case if you are wondering about how to tag commits locally and then push them to git, check the attached.
push

@stuhli

This comment has been minimized.

Copy link

stuhli commented Oct 11, 2018

Thanks!

@tapkain

This comment has been minimized.

Copy link

tapkain commented Oct 13, 2018

Thanks!

@RainyLi

This comment has been minimized.

Copy link

RainyLi commented Oct 16, 2018

Thanks! Longest comments list ever πŸ‘

@ideoclickVanessa

This comment has been minimized.

Copy link

ideoclickVanessa commented Oct 19, 2018

Is there a way to achieve the results of this gist when you do not have ForcePush permissions on the origin?

@craidler

This comment has been minimized.

Copy link

craidler commented Oct 22, 2018

Thanks!

@mverteuil

This comment has been minimized.

Copy link

mverteuil commented Oct 27, 2018

πŸ‘

@vikashnarayan

This comment has been minimized.

Copy link

vikashnarayan commented Dec 3, 2018

Thanks!!!

@Antalinka

This comment has been minimized.

Copy link

Antalinka commented Dec 19, 2018

thanks

@elissonmichael

This comment has been minimized.

Copy link

elissonmichael commented Jan 1, 2019

Thanks for sharing this.

@hadv

This comment has been minimized.

Copy link

hadv commented Jan 19, 2019

Thanks!
I had to delete a lot of tags wich were very similar (i.e. 2.0.0-1, 2.0.0-2, 2.0.0-3), so this is what I did:

git tag --list '2.0.0-*' | xargs -I % echo "git tag -d %; git push --delete origin %" | sh

It's very helpful! TFS!

@Shhhpoulpe

This comment has been minimized.

Copy link

Shhhpoulpe commented Feb 6, 2019

Thanks!

@Rubenvdveen

This comment has been minimized.

Copy link

Rubenvdveen commented Feb 7, 2019

Thanks!

@christianhaller3000

This comment has been minimized.

Copy link

christianhaller3000 commented Feb 12, 2019

thanks

@ikendoit

This comment has been minimized.

Copy link

ikendoit commented Feb 16, 2019

Wonderful, Thank you !

@chrisgleissner

This comment has been minimized.

Copy link

chrisgleissner commented Feb 17, 2019

Thanks, appreciated!

@byrondevonwall

This comment has been minimized.

Copy link

byrondevonwall commented Feb 21, 2019

thanks!

@bobbydeveaux

This comment has been minimized.

Copy link

bobbydeveaux commented Feb 28, 2019

thnx

@levmichael3

This comment has been minimized.

Copy link

levmichael3 commented Mar 3, 2019

thanks!

@darealshinji

This comment has been minimized.

Copy link

darealshinji commented Mar 6, 2019

Thanks.

@supadupdip

This comment has been minimized.

Copy link

supadupdip commented Mar 7, 2019

gracias

@telmott

This comment has been minimized.

Copy link

telmott commented Mar 8, 2019

πŸ‘ thanks.

@mahditakrim

This comment has been minimized.

Copy link

mahditakrim commented Mar 9, 2019

love you man

@man0ni

This comment has been minimized.

Copy link

man0ni commented Mar 12, 2019

πŸ‘ Thank you a lot !

@FredricW

This comment has been minimized.

Copy link

FredricW commented Mar 14, 2019

Thanks!

@Defranos

This comment has been minimized.

Copy link

Defranos commented Mar 14, 2019

Thanks!

@SahinU88

This comment has been minimized.

Copy link

SahinU88 commented Mar 19, 2019

πŸ€™

@bazmera

This comment has been minimized.

Copy link

bazmera commented Mar 21, 2019

Thank you

@GriffinG1

This comment has been minimized.

Copy link

GriffinG1 commented Mar 22, 2019

danke schoen

@MrArshaX

This comment has been minimized.

Copy link

MrArshaX commented Mar 26, 2019

Thanks!

@DpEpsilon

This comment has been minimized.

Copy link

DpEpsilon commented Mar 27, 2019

ty

@xanaDev

This comment has been minimized.

Copy link

xanaDev commented Mar 28, 2019

thanks πŸ‘

@aftab70

This comment has been minimized.

Copy link

aftab70 commented Apr 1, 2019

Thanks!

@Tarasovych

This comment has been minimized.

Copy link

Tarasovych commented Apr 3, 2019

Thanks!

@AlexFoxJS

This comment has been minimized.

Copy link

AlexFoxJS commented Apr 3, 2019

Thanks

@DimitrijeManic

This comment has been minimized.

Copy link

DimitrijeManic commented Apr 5, 2019

Thanks

@orlanrepo

This comment has been minimized.

Copy link

orlanrepo commented Apr 8, 2019

Thanks!

@albertomota-codes

This comment has been minimized.

Copy link

albertomota-codes commented Apr 10, 2019

thanks!

@MrMahdi313

This comment has been minimized.

Copy link

MrMahdi313 commented Apr 12, 2019

Nice.
Really thanks.

@YakirGiladi

This comment has been minimized.

Copy link

YakirGiladi commented Apr 14, 2019

thanks !

@harrytruong

This comment has been minimized.

Copy link

harrytruong commented Apr 16, 2019

thanks!

@DanielRiezebos

This comment has been minimized.

Copy link

DanielRiezebos commented Apr 16, 2019

Thank you very much! :D

@langsmith

This comment has been minimized.

Copy link

langsmith commented Apr 17, 2019

Awesome. Thanks.

@d0vgan

This comment has been minimized.

Copy link

d0vgan commented Apr 19, 2019

sorry for saying this, but if git was a tool designed for users (i.e. an intuitive tool), there would be one git command for doing this!

@jozr

This comment has been minimized.

Copy link

jozr commented May 15, 2019

Thanks!

@linneakw

This comment has been minimized.

Copy link

linneakw commented May 22, 2019

you da best music

@tremaineeto

This comment has been minimized.

Copy link

tremaineeto commented Jun 4, 2019

Adding to the crowd: thanks!

@jerry-james

This comment has been minimized.

Copy link

jerry-james commented Jun 5, 2019

Thanks

@tavisca-apaithane

This comment has been minimized.

Copy link

tavisca-apaithane commented Jun 18, 2019

thanks bro..:)

@KSoto

This comment has been minimized.

Copy link

KSoto commented Jun 21, 2019

continuing this thanks train

thanks ;)

@elonderin

This comment has been minimized.

Copy link

elonderin commented Jun 24, 2019

as i want to be able to spec multiple args on the CLI manually i adjusted like so:
tag-kill = "!f() { for t in "$*"; do echo "git tag -d $t && git push --delete o $t " | bash -x ; done; }; f "

@bitfisher

This comment has been minimized.

Copy link

bitfisher commented Jun 28, 2019

Awesome. Thanks.

@tuzz

This comment has been minimized.

Copy link

tuzz commented Jun 30, 2019

Thanks.

@kartik7153

This comment has been minimized.

Copy link

kartik7153 commented Jul 2, 2019

Thanks.

@mmesnjak

This comment has been minimized.

Copy link

mmesnjak commented Jul 2, 2019

remove-tags = "!f() { git tag -l ${1} | xargs -I % echo "git tag -d % && git push --delete origin %" | sh; }; f"

I would just add one more check in this alias:

remove-tags = "!f() { [ -z ${1} ] && echo \"No tags given as an argument!\" || (git tag -l ${1} | xargs -I % echo \"git tag -d % && git push --delete origin %\" | sh); }; f"

Otherwise all the tags get removed locally and at the origin :(

@NBorba

This comment has been minimized.

Copy link

NBorba commented Jul 3, 2019

Thanks!

@esynaps

This comment has been minimized.

Copy link

esynaps commented Jul 5, 2019

thanks

@LachlanMcLachlan

This comment has been minimized.

Copy link

LachlanMcLachlan commented Jul 5, 2019

Thanks!

@klanjabrik

This comment has been minimized.

Copy link

klanjabrik commented Jul 9, 2019

Thanks!

@ra1fee

This comment has been minimized.

Copy link

ra1fee commented Jul 10, 2019

Thanks

@walbertus

This comment has been minimized.

Copy link

walbertus commented Jul 10, 2019

Thanks

@lubiepomaranczki

This comment has been minimized.

Copy link

lubiepomaranczki commented Jul 10, 2019

That's the hero we need but don't deserve! Thanks! πŸ™Œ

@TeamDman

This comment has been minimized.

Copy link

TeamDman commented Jul 12, 2019

Thanks!

@DreamerDeLy

This comment has been minimized.

Copy link

DreamerDeLy commented Jul 20, 2019

Thanks

@RajatJain4061

This comment has been minimized.

Copy link

RajatJain4061 commented Jul 25, 2019

Thanks πŸ‘

@tmihai20

This comment has been minimized.

Copy link

tmihai20 commented Jul 25, 2019

Thanks, it was a huge helper.

@pedropaislopes

This comment has been minimized.

Copy link

pedropaislopes commented Aug 1, 2019

Thanks a lot!

@DavidCarcamo

This comment has been minimized.

Copy link

DavidCarcamo commented Aug 1, 2019

Gracias!

@RenanMonteiroS

This comment has been minimized.

Copy link

RenanMonteiroS commented Aug 1, 2019

Thanks, very helpful.

@Vitucho

This comment has been minimized.

Copy link

Vitucho commented Aug 2, 2019

THANKS for sharing!

@hoomanist

This comment has been minimized.

Copy link

hoomanist commented Aug 13, 2019

thanks it helps me a lot

@avisper

This comment has been minimized.

Copy link

avisper commented Aug 14, 2019

thanks for sharing :)

@sanket4373

This comment has been minimized.

Copy link

sanket4373 commented Aug 21, 2019

thanks for sharing!

@ugurozturk

This comment has been minimized.

Copy link

ugurozturk commented Aug 25, 2019

Thanks

@jessosketch

This comment has been minimized.

Copy link

jessosketch commented Aug 26, 2019

thanks! πŸ‘

@ccarstens

This comment has been minimized.

Copy link

ccarstens commented Aug 31, 2019

Thank you!

@helgso

This comment has been minimized.

Copy link

helgso commented Sep 5, 2019

Thanks :D

@igorminotto

This comment has been minimized.

Copy link

igorminotto commented Sep 5, 2019

πŸ”

@ASOEstudio

This comment has been minimized.

Copy link

ASOEstudio commented Sep 10, 2019

Nice! :D

@liaojingmath

This comment has been minimized.

Copy link

liaojingmath commented Sep 16, 2019

Thanks!

@SupraLP

This comment has been minimized.

Copy link

SupraLP commented Sep 16, 2019

Thanks :3

@reivaxzoom

This comment has been minimized.

Copy link

reivaxzoom commented Sep 16, 2019

thanks

@Ghanshyam-K-Dobariya

This comment has been minimized.

Copy link

Ghanshyam-K-Dobariya commented Sep 20, 2019

Thanks it helped...

@mrk-han

This comment has been minimized.

Copy link

mrk-han commented Sep 23, 2019

Thank you!

@anologicon

This comment has been minimized.

Copy link

anologicon commented Sep 25, 2019

Nice!

@valdiss

This comment has been minimized.

Copy link

valdiss commented Sep 27, 2019

Thanks!

@kvzl

This comment has been minimized.

Copy link

kvzl commented Sep 30, 2019

Thanks!

@inside

This comment has been minimized.

Copy link

inside commented Oct 1, 2019

Thanks!

@manzurahammed

This comment has been minimized.

Copy link

manzurahammed commented Oct 1, 2019

thanks

@simformsolutions

This comment has been minimized.

Copy link

simformsolutions commented Oct 2, 2019

Thanks!

@crazilazi

This comment has been minimized.

Copy link

crazilazi commented Oct 3, 2019

Thanks.

@SamWheating

This comment has been minimized.

Copy link

SamWheating commented Oct 3, 2019

Thanks !

@jimhavrilla

This comment has been minimized.

Copy link

jimhavrilla commented Oct 8, 2019

You sir, are a legend.

@Lycea

This comment has been minimized.

Copy link

Lycea commented Oct 8, 2019

thx!

@mrtnmgs

This comment has been minimized.

Copy link

mrtnmgs commented Oct 8, 2019

I visit this page on a weekly basis. Thanks!

@mouradev

This comment has been minimized.

Copy link

mouradev commented Oct 9, 2019

Thanks!

@qiuncheng

This comment has been minimized.

Copy link

qiuncheng commented Oct 12, 2019

thanks!

@zhixu

This comment has been minimized.

Copy link

zhixu commented Oct 17, 2019

Thanks!

@oheil

This comment has been minimized.

Copy link

oheil commented Oct 18, 2019

Great! Thank you! Helps keeping things clean!

@TimoBakx

This comment has been minimized.

Copy link

TimoBakx commented Oct 22, 2019

Exactly what I was googling for. Thanks!

@olehhutsalo

This comment has been minimized.

Copy link

olehhutsalo commented Oct 23, 2019

Thanks

@ivanstnsk

This comment has been minimized.

Copy link

ivanstnsk commented Oct 30, 2019

Thanks!! πŸ‘

@Bharathkumarraju

This comment has been minimized.

Copy link

Bharathkumarraju commented Nov 6, 2019

Thanks!!!

@juanefec

This comment has been minimized.

Copy link

juanefec commented Nov 6, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.