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.
Checkout more articles on Git
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.
1 | 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 <tag_name>
.
2. Get tag list
We can list the available tags in our repository using following command.
1 | git tag |
Use the following command to check the details of a particular tag.
1 | git tag show <tag_name> |
3. Search tags using patterns
You can also search the list of tags using patterns.
1 2 3 4 | git tag -l "<patterns>*" // Example git tag -l "ver*" |
4. Create a annotated tag
Annotated tags are tags that store extra metadata like developer name, email, date, and more.
1 | 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.
1 | git push origin <tag_name> |
Use the --tags
to push all the tags to the remote repository.
1 | git push origin --tags |
6. Checkout tag
Run the following command to checkout the perticular tag.
1 | git checkout <tag_name> |
7. Delete tag locally
Use the following command to delete a tag locally.
1 | 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.
1 | 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.
1 | git checkout -b <branch_name> <tag_name> |
I hope you find this article helpful.
Thank you for reading. Happy Coding..!! 🙂