5

I have a tag called latest and I want that to be a branch instead. Opposite of this. I need to remove it from the remote repo as well.

Background: This is currently a problem for many golang packages, where goinstall looks for a release tag or branch, which corresponds with the latest official release of the language. Many people mistakenly used git tags, by analogy with other VCSes, when they should have used git branches.

Community
  • 1
  • 1
cdunn2001
  • 17,657
  • 8
  • 55
  • 45

2 Answers2

7
git checkout latest
git tag -d latest  # delete tag locally
git push origin :refs/tags/latest  # delete tag in repo
git checkout -b latest
git push origin latest

The danger of removing a tag is described here, but that is why a branch should have been used in the first place.

cdunn2001
  • 17,657
  • 8
  • 55
  • 45
  • I don't believe a delete followed by a create is the same things as a converting an existing tag into a branch. Was it the case (is it still the case?) that one cannot convert a tag into a branch? That question does not appear to be answered. – jww Sep 07 '16 at 22:05
  • A "branch" (really a "head") is nothing but a file like `.git/refs/heads/mybranch`, containing just a SHA1. A "lightweight tag" is also just a file containing a SHA1, like `.git/refs/tags/mytag`. So you *could* simply `mv` that file. But an "annotated tag" is a bit more. – cdunn2001 Sep 27 '16 at 22:54
1

Instead of deleting the tag use a branch of a different name. Use different naming conventions for your branches and your tags. This will better allow you to fullfil the spirit of

  • Branches are for changes, tags are for releases
  • Don't delete tags
Bill Door
  • 18,272
  • 3
  • 32
  • 37
  • 1
    Ideally, yes. The problem is that lots of people have created tags they should not have. In other VCSes, tags can be moved, so they apply the same model to git. I'll change the word *release* to *latest* to make it more clear. – cdunn2001 Jul 24 '11 at 19:47