How do i recreate a Git Tag ?

Rahul juneja
2 min readFeb 5, 2020

Git Tags are ref’s that point to specific points in history. They are usually created to make releases or freeze the code at certain point. A tag is like a branch that doesn’t update. You can create and delete tags using git shell or at github.com.

Before starting, you should know about tag naming. Tag can be named as you want (like test, hola, latest, stage, staging etc.). Mostly they are named as (1.0.0, 1.1.0, 2.0.1 etc.) which is good practice to always create a new Tag for each Major or Minor release. But sometimes your needs are different , you only want to maintain the same tag. Then you want to update them. So to update them you first have to Delete the Old one and Create the new with same name.

Git Tags can be stored locally or on remote or on both.

First we learn how to create a tag. So in order to create you first decide which branch code you want freeze or create a tag from. In this we’ll only be using master branch and the tag name would be latest.

To Create a local tag (local means on host machine not on github), first we need to go to the branch and then we’ll create the tag like:

$ git checkout master
$ git tag latest

Notice: if your .git folder is protected then please use sudo before git.

To verify the tag is created or not enter:

$ git tag
latest

To push a Local Tag to remote (github) use:

$ git push origin latest

Now we’ll move ahead to delete a tag locally:

$ git tag -d latest

To delete a tag from remote:

$ git push --delete origin refs/tags/latest

It seems the time for dessert. lets do recreate the tag:

$ git tag -d latest
$ git push --delete origin refs/tags/latest
$ git checkout master
$ git tag latest
$ git push origin latest

--

--