How to delete Git tag named starting with dash?

2019-07-26 18:42发布

问题:

I tried deleting the git tag name which is named as -d using command git tag -d -d but couldn't able to delete it.

Any ideas?

回答1:

git tag -d -- -d is the usual way to tell a *nix program that the argument after -- is not an option but rather a positional argument. This is how you can remove files named -f and so on.



回答2:

I had the same issue.

git tag -d -- -d

did not work for me.

However this did work:

git tag -d `git tag -l '*-d*'`

Explanation:

  • List tags matching *-d*
  • Pass resulting list to git tag -d