cdunn2001
cdunn2001

Reputation: 18257

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.

Upvotes: 5

Views: 4878

Answers (2)

cdunn2001
cdunn2001

Reputation: 18257

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.

Upvotes: 7

Bill Door
Bill Door

Reputation: 18916

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

Upvotes: 1

Related Questions