How to work with Git tag

I have put this information about git tags together, mostly so I do the right thing when I work with Git Repositories. It might be helpful information for anyone working with git.

Add New Tag

Add a new tag for the updated release

git tag -a v1.52 -m "Update to release"

Then you have to push the tag to the origin, with this command

git push origin --tags

Push tags

git push --tags

or if you are looking to push a single tag:

git push origin
git push [[<repository> [<refspec>…]]


The format of a <refspec> parameter is…the source ref <src>, followed by a colon :, followed by the destination ref <dst>

The <dst> tells which ref on the remote side is updated with this push…If :<dst> is omitted, the same ref as <src> will be updated…

tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>.

Push All of Your Tags at Once

git push --tags <remote>
# Or
git push <remote> --tags
git push [--all | --mirror | --tags] [<repository> [<refspec>…]]


All refs under refs/tags are pushed, in addition to refspecs explicitly listed on the command line.

Delete a git tag

Deleting a git tag does not happen that often (if ever at all) but just in case, here is how to delete a tag from a remote Git repository.

Delete git tag locally:

git tag -d v1.0

Delete on remote, If you have a tag named ‘v0.5’ then you would just do this:

git tag -d v0.5
git push origin :refs/tags/v0.5

That will remove ‘v0.5’ from the remote repository.



, ,




Leave a Reply

Your email address will not be published. Required fields are marked *