3

I am trying to delete a tag in the remote. I get conflicting answers - "tag does not exist" and then "tag was deleted", but when I check, the tag is still there. There is a similar question here (meaning of git push tag error: "Deleting a non-existent ref.") but it does not help in my case. Thanks

% git --version 
git version 2.11.0
% git ls-remote 2>/dev/null | grep amirk|grep '\.72$'
68a1595db91fca0cc1fa24566e9e7173fcd05c5e    refs/tags/Forked_branch_amirk/test-10.0.0.72
% git push origin :refs/tags/Forked_Branch_amirk/test-10.0.0.72 
remote: warning: Deleting a non-existent ref.
To <my-remote-git-repo>
- [deleted]               Forked_Branch_amirk/test-10.0.0.72
% git ls-remote 2>/dev/null | grep amirk|grep '\.72$'            
68a1595db91fca0cc1fa24566e9e7173fcd05c5e    refs/tags/Forked_branch_amirk/test-10.0.0.72
Community
  • 1
  • 1
Amir Katz
  • 643
  • 2
  • 10
  • 23

3 Answers3

2

The "deleting a non-existent ref" indicates that it's not there, but the git ls-remote output indicates that it is there. The two obvious options at this point are:

  • the tag is there but is subtly spelled differently than it appears, e.g., the branch name has some invisible character(s) in it, or
  • the push is not going to the same server as the ls-remote, e.g., you have defined separate fetch and push URLs, or your current branch has a remote other than origin set.

The latter seems more likely. To check, run git config --get branch.$(git symbolic-ref --short HEAD).remote, to make sure that the current branch's remote really is origin; and if so, run git remote show origin or git remote show -n origin.

torek
  • 448,244
  • 59
  • 642
  • 775
  • I checked option 1 and the spelling is good. However, I forgot to mention (which may shed more light on the problem) that for every tag that I push, I see another tag like this (with up-arrow and open/close curly braces): 1629064fcf60677bedaa3278e742d3964b887de9 refs/tags/Forked_branch_amirk/test-10.0.0.72^{} – Amir Katz Dec 14 '16 at 07:29
  • Checked option 2 and it's origin. Another data point - I tried it from another Linux (which has an older git version, 2.7.4) and was able to successfully delete the tag from the remote (and it also deletes the tag with ^{}). I also verified that my ~/.gitconfig file is not the problem, so maybe the bug is in git 2.11.0? – Amir Katz Dec 14 '16 at 07:50
  • 1
    The `^{}` thing indicates that the tag is an *annotated* tag, and the first value (without the suffix) is the hash of the tag object, with the second value being the hash of the tagged thing (commit, usually). So that part is normal. The fact that the delete fails with only Git 2.11.0 does imply a bug in Git 2.11.0. I just upgraded my Mac and got 2.11.0, I'm running 2.10.1 on the machine I usually use, so I have no experience with 2.11.0 yet. – torek Dec 14 '16 at 08:59
1

It's still unclear why the standard syntax (git push origin :refs/tags/tagname) does not work on my system. But here is an alternative syntax that does work:

git push --delete origin Forked_branch_amirk/test-10.0.0.36
Amir Katz
  • 643
  • 2
  • 10
  • 23
  • As per http://stackoverflow.com/users/1256452/torek (who provided useful input) and as per my tests, it seems to be a bug in git 2.11.0. It happens on Ubuntu 14.04, but probably will happen on other OS's as well. – Amir Katz Dec 14 '16 at 10:28
1

You cannot delete a tag if it has a corresponding release. It is disabled by default.

To delete a tag that already has a corresponding release, do the following:

  • Go to your github repo and go to code tab.
  • Go to releases (right side)
  • From releases, delete the corresponding release using the tag.
  • Go to tags, delete the tag
manojadams
  • 2,314
  • 3
  • 26
  • 30