Using tags in Git
Today we’ll give you an understanding of the tags and show you a list of git commands to play with tags.
Tagging in Git
- Create a light-weighted tag
- Get tag list
- Search tags using patterns
- Create a annotated tag
- Push tag to the remote repository
- Checkout tag
- Delete tag locally
- Delete tag remotely
- Create a new branch from tag
1. Create a light-weighted tag
To create a tag, run the following command. It’s also known as a light-weighted tag.
git tag <tag_name>
Make sure you will checkout the branch where you want to create a tag.
The above tag command will create a mark point on the branch as
2. Get tag list
We can list the available tags in our repository using following command.
Use the following command to check the details of a particular tag.
git tag show <tag_name>
3. Search tags using patterns
You can also search the list of tags using patterns.
git tag -l "<patterns>*"
git tag -l "ver*"
4. Create a annotated tag
Annotated tags are tags that store extra metadata like developer name, email, date, and more.
git tag <tag_name> -m "<tag_message>"
5. Push tag to the remote repository
Use the following command to push the particular tag to the remote repository.
git push origin <tag_name>
--tags to push all the tags to the remote repository.
git push origin --tags
6. Checkout tag
Run the following command to checkout the perticular tag.
git checkout <tag_name>
7. Delete tag locally
Use the following command to delete a tag locally.
git tag -d <tag_name>
8. Delete tag remotely
After deleting the tag from local, you can still see the tag on remote repository. So run the following command to delete a tag from a remote repository.
git push origin -d <tag_name>
9. Create a new branch from tag
If you want to create a new branch from a specific tag then use the following command.
git checkout -b <branch_name> <tag_name>
I hope you find this article helpful.
Thank you for reading. Happy Coding..!! 🙂