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

commented Jul 27, 2017

thanks for the indirect help

@Jonathan-Rosewood

This comment has been minimized.

Copy link

commented Aug 11, 2017

Yep, thanks

@Dianna

This comment has been minimized.

Copy link

commented Aug 15, 2017

Thanks!

@alexismaster

This comment has been minimized.

Copy link

commented Sep 21, 2017

Thanks!

@arturmamedov

This comment has been minimized.

Copy link

commented Sep 27, 2017

Thank you man!

@shrishty

This comment has been minimized.

Copy link

commented Oct 4, 2017

Thanks

@konekoya

This comment has been minimized.

Copy link

commented Oct 12, 2017

Thanks for sharing this ๐Ÿ’ฏ

@natec8

This comment has been minimized.

Copy link

commented Oct 13, 2017

Thanks

@jamjon3

This comment has been minimized.

Copy link

commented Oct 30, 2017

Thanks!

@iberck

This comment has been minimized.

Copy link

commented Nov 8, 2017

Thanks

@andfoy

This comment has been minimized.

Copy link

commented Nov 20, 2017

Thanks!

@Chrispassold

This comment has been minimized.

Copy link

commented Nov 23, 2017

Thanks!

@Campano

This comment has been minimized.

Copy link

commented Nov 28, 2017

+1

@vishalvijay

This comment has been minimized.

Copy link

commented Nov 29, 2017

+1

@EvgenyUnvsoft

This comment has been minimized.

Copy link

commented Nov 30, 2017

thanks!

@arecvlohe

This comment has been minimized.

Copy link

commented Dec 13, 2017

Thanks!

@DoNotSpamPls

This comment has been minimized.

Copy link

commented Dec 25, 2017

Thanks!

@PhaserEditor2D

This comment has been minimized.

Copy link

commented Dec 28, 2017

+1

@Firecul

This comment has been minimized.

Copy link

commented Jan 1, 2018

Thank you

@paxperscientiam

This comment has been minimized.

Copy link

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

commented Jan 26, 2018

Thanks!

@jockerxlj

This comment has been minimized.

Copy link

commented Jan 30, 2018

Thanks๏ผ

@BradleyA

This comment has been minimized.

Copy link

commented Feb 7, 2018

thanks!

@joh-klein

This comment has been minimized.

Copy link

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

commented Feb 7, 2018

Nice.
Thanks

@msta

This comment has been minimized.

Copy link

commented Feb 8, 2018

Thanks

@gtdeng

This comment has been minimized.

Copy link

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

commented Feb 27, 2018

๐Ÿ’ฏ Thanks ๐Ÿ‘

@matiasa18

This comment has been minimized.

Copy link

commented Mar 1, 2018

Thank you, worked like a charm!

@TimRChen

This comment has been minimized.

Copy link

commented Mar 16, 2018

Thanks!

@Chamuth

This comment has been minimized.

Copy link

commented Mar 19, 2018

Thank you very much

@joshhunt

This comment has been minimized.

Copy link

commented Mar 20, 2018

Thanks!

@liranfar

This comment has been minimized.

Copy link

commented Mar 22, 2018

Thanks a lot! ๐Ÿฅ‡

@petrewoo

This comment has been minimized.

Copy link

commented Mar 23, 2018

Thx!

@DenisK2017

This comment has been minimized.

Copy link

commented Apr 2, 2018

Thank you very much!

@AlexanderTserkovniy

This comment has been minimized.

Copy link

commented Apr 16, 2018

Thanks!

@anahiem

This comment has been minimized.

Copy link

commented Apr 16, 2018

THANKS!

@devmike01

This comment has been minimized.

Copy link

commented Apr 25, 2018

Thank you.

@astrieanna

This comment has been minimized.

Copy link

commented Apr 30, 2018

Thank you ๐Ÿ‘

@SoftDev0420

This comment has been minimized.

Copy link

commented May 2, 2018

Thank you.

@Budyn

This comment has been minimized.

Copy link

commented May 15, 2018

Thanks

@Erkin97

This comment has been minimized.

Copy link

commented May 18, 2018

thanks :)

@fuchao2012

This comment has been minimized.

Copy link

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

commented Jun 5, 2018

gracias!

@kansalaman

This comment has been minimized.

Copy link

commented Jun 6, 2018

Thanks!!

@jv-oliveira

This comment has been minimized.

Copy link

commented Jun 7, 2018

thank you!

@apmason

This comment has been minimized.

Copy link

commented Jun 8, 2018

Thanks!

@Smosker

This comment has been minimized.

Copy link

commented Jun 11, 2018

thanks!

@isaac-weisberg

This comment has been minimized.

Copy link

commented Jun 12, 2018

Thank you very much, appreciate it.

@LanguidSquid

This comment has been minimized.

Copy link

commented Jun 14, 2018

Thanks, good looking out fam

@itschmp

This comment has been minimized.

Copy link

commented Jun 21, 2018

Many thanks. Nice approach to help dear fellows developers.

@Maksio

This comment has been minimized.

Copy link

commented Jun 25, 2018

thank you very much!

@martiis

This comment has been minimized.

Copy link

commented Jun 28, 2018

Very nais, thank you :D

@heknt

This comment has been minimized.

Copy link

commented Jun 30, 2018

Thanks, really helped me!

@colinwilson

This comment has been minimized.

Copy link

commented Jul 2, 2018

Thank you. ๐Ÿ‘

@Erkin97

This comment has been minimized.

Copy link

commented Jul 4, 2018

thanks

@giovaninppc

This comment has been minimized.

Copy link

commented Jul 5, 2018

Thanks!

@ihsoft

This comment has been minimized.

Copy link

commented Jul 17, 2018

Awesome! Thanks.

@JervyShi

This comment has been minimized.

Copy link

commented Jul 17, 2018

Thanks!

@Bijan-Ghasemi-Afshar

This comment has been minimized.

Copy link

commented Jul 18, 2018

Thanks!

@gvdm90

This comment has been minimized.

Copy link

commented Jul 19, 2018

Thanks!

@henriquellemos

This comment has been minimized.

Copy link

commented Jul 20, 2018

Thanks!

@roberGzt

This comment has been minimized.

Copy link

commented Aug 1, 2018

Thanks!

@ivolivares

This comment has been minimized.

Copy link

commented Aug 1, 2018

Thanks!

@maynalysa

This comment has been minimized.

Copy link

commented Aug 3, 2018

Thanks !

@marceloalejoc

This comment has been minimized.

Copy link

commented Aug 3, 2018

Thanks! +1

@Wizzzo

This comment has been minimized.

Copy link

commented Aug 5, 2018

Great!
Thanks

@splait

This comment has been minimized.

Copy link

commented Aug 8, 2018

Thanks

@NSMyself

This comment has been minimized.

Copy link

commented Aug 9, 2018

Thanks!

@werbth

This comment has been minimized.

Copy link

commented Aug 11, 2018

Thanks!

@CSaratakij

This comment has been minimized.

Copy link

commented Aug 19, 2018

๐Ÿ‘

@ghost

This comment has been minimized.

Copy link

commented Aug 21, 2018

Thanks

@noamhacker

This comment has been minimized.

Copy link

commented Sep 20, 2018

Thanks!

@lamg

This comment has been minimized.

Copy link

commented Sep 26, 2018

Thanks!!

@lemon-clown

This comment has been minimized.

Copy link

commented Oct 4, 2018

Thanks!

@WilliamPourmajidi

This comment has been minimized.

Copy link

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

commented Oct 11, 2018

Thanks!

@tapkain

This comment has been minimized.

Copy link

commented Oct 13, 2018

Thanks!

@RainyLi

This comment has been minimized.

Copy link

commented Oct 16, 2018

Thanks! Longest comments list ever ๐Ÿ‘

@ideoclickVanessa

This comment has been minimized.

Copy link

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

commented Oct 22, 2018

Thanks!

@mverteuil

This comment has been minimized.

Copy link

commented Oct 27, 2018

๐Ÿ‘

@vikashnarayan

This comment has been minimized.

Copy link

commented Dec 3, 2018

Thanks!!!

@Antalinka

This comment has been minimized.

Copy link

commented Dec 19, 2018

thanks

@elissonmichael

This comment has been minimized.

Copy link

commented Jan 1, 2019

Thanks for sharing this.

@hadv

This comment has been minimized.

Copy link

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

commented Feb 6, 2019

Thanks!

@Rubenvdveen

This comment has been minimized.

Copy link

commented Feb 7, 2019

Thanks!

@christianhaller3000

This comment has been minimized.

Copy link

commented Feb 12, 2019

thanks

@ikendoit

This comment has been minimized.

Copy link

commented Feb 16, 2019

Wonderful, Thank you !

@chrisgleissner

This comment has been minimized.

Copy link

commented Feb 17, 2019

Thanks, appreciated!

@byrondevonwall

This comment has been minimized.

Copy link

commented Feb 21, 2019

thanks!

@bobbydeveaux

This comment has been minimized.

Copy link

commented Feb 28, 2019

thnx

@levmichael3

This comment has been minimized.

Copy link

commented Mar 3, 2019

thanks!

@darealshinji

This comment has been minimized.

Copy link

commented Mar 6, 2019

Thanks.

@supadupdip

This comment has been minimized.

Copy link

commented Mar 7, 2019

gracias

@telmott

This comment has been minimized.

Copy link

commented Mar 8, 2019

๐Ÿ‘ thanks.

@mahditakrim

This comment has been minimized.

Copy link

commented Mar 9, 2019

love you man

@man0ni

This comment has been minimized.

Copy link

commented Mar 12, 2019

๐Ÿ‘ Thank you a lot !

@FredricW

This comment has been minimized.

Copy link

commented Mar 14, 2019

Thanks!

@Defranos

This comment has been minimized.

Copy link

commented Mar 14, 2019

Thanks!

@SahinU88

This comment has been minimized.

Copy link

commented Mar 19, 2019

๐Ÿค™

@bazmera

This comment has been minimized.

Copy link

commented Mar 21, 2019

Thank you

@GriffinG1

This comment has been minimized.

Copy link

commented Mar 22, 2019

danke schoen

@MrArshaX

This comment has been minimized.

Copy link

commented Mar 26, 2019

Thanks!

@DpEpsilon

This comment has been minimized.

Copy link

commented Mar 27, 2019

ty

@xanaDev

This comment has been minimized.

Copy link

commented Mar 28, 2019

thanks ๐Ÿ‘

@aftab70

This comment has been minimized.

Copy link

commented Apr 1, 2019

Thanks!

@Tarasovych

This comment has been minimized.

Copy link

commented Apr 3, 2019

Thanks!

@AlexFoxJS

This comment has been minimized.

Copy link

commented Apr 3, 2019

Thanks

@DimitrijeManic

This comment has been minimized.

Copy link

commented Apr 5, 2019

Thanks

@orlanrepo

This comment has been minimized.

Copy link

commented Apr 8, 2019

Thanks!

@albertomota-codes

This comment has been minimized.

Copy link

commented Apr 10, 2019

thanks!

@MrMahdi313

This comment has been minimized.

Copy link

commented Apr 12, 2019

Nice.
Really thanks.

@YakirGiladi

This comment has been minimized.

Copy link

commented Apr 14, 2019

thanks !

@harrytruong

This comment has been minimized.

Copy link

commented Apr 16, 2019

thanks!

@DanielRiezebos

This comment has been minimized.

Copy link

commented Apr 16, 2019

Thank you very much! :D

@langsmith

This comment has been minimized.

Copy link

commented Apr 17, 2019

Awesome. Thanks.

@d0vgan

This comment has been minimized.

Copy link

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

commented May 15, 2019

Thanks!

@linneakw

This comment has been minimized.

Copy link

commented May 22, 2019

you da best music

@tremaineeto

This comment has been minimized.

Copy link

commented Jun 4, 2019

Adding to the crowd: thanks!

@jerry-james

This comment has been minimized.

Copy link

commented Jun 5, 2019

Thanks

@tavisca-apaithane

This comment has been minimized.

Copy link

commented Jun 18, 2019

thanks bro..:)

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.