Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Converting tag to branch in remote repo

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.

like image 313
cdunn2001 Avatar asked Jul 23 '11 19:07

cdunn2001


2 Answers

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.

like image 198
cdunn2001 Avatar answered Oct 28 '22 03:10

cdunn2001


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
like image 37
Bill Door Avatar answered Oct 28 '22 05:10

Bill Door