Git Tag
A tag in Git contexts is used for marking a specific version. Alternatively, tags are used to mark specific points in the history as important or to mark release points. In common words we can say that tag is used to specify a specific version of your codebase in the repository.
As we can see that there is no tag in our repository for now
Create and push a tag in github repository
- Go to your local repository that you have cloned on your local system.
- To list down the existing tags in your repository, just execute
git tag -l
It will list down all the existing tags, if no tag is created it will show us nothing
- For creating new tag, execute
git tag -a <Tag-Name> -m <Tag-Message>
now if we will do git tag -l it will show us the tag
For demo purpose we have used drillers-0.1 as a tag-name
To push our newly created tag to remote repository we will usegit push origin <Tag-Name>
As we can see our tag is pushed to our repository and we have a tag in our repository.
Delete a tag in github repository
- Go to your local repository that you have cloned on your local system
- Execute git tag -l and a list of all the existing tags will be displayed
- Now select the tag that you want to delete (drillers-0.1) in our case and execute
git tag -d <tag-name-to-be-deleted>
- Now if you will list down the tag in local repository you won’t be seeing any tag over there
- Push the deleted tag to our remote repository
git push origin :refs/tags/<tag-name-to-be-deleted>
Now if you will check in your repository there will not be any tag in remote repository
NOTE:-Git Tag is used to identify and labeling a commit in branch to benchmark up to a point. Tagging is used for branch which is deployed to Staging or Production environment for identification of important release.