git tag - How can I create a git alias to delete a tag remotely? -
i'm having trouble creating git alias delete tag remotely.
i have following in .gitconfig
:
[alias] deltag = push origin :refs/tags/$1
running deltag
alias after deleting tag locally (with git tag -d testtag
) results in error:
$ git deltag testtag error: src refspec testtag not match any. error: failed push refs 'ssh://........'
attempting run alias before deleting locally results in instead:
$ git deltag testtag remote: warning: deleting non-existent ref. ssh://........ - [deleted] $1
what correct syntax use alias?
i solved hunting around on stackoverflow , putting other answers together.
there may other solutions too, turning alias shell command passes tag argument through:
[alias] deltag = !sh -c 'git push origin :refs/tags/$1' -
or better, combining both local , remote delete 1 alias:
[alias] deltag = !sh -c 'git tag -d $1 && git push origin :refs/tags/$1' -
the output:
$ git deltag testtag deleted tag 'testtag' (was be73a23) ssh://....... - [deleted] testtag