Tagging In Git
Tagging allows us to mark a specific point in the commit history (snapshot). A tag is typically used to mark a project release.
Tags in Git can be of two types:
- Lightweight Tag
- Annotated Tag
A lightweight tag is just a pointer to a specific point in the commit history. It is basically used to tag a point temporarily. It does not store any information other than the commit point information.
Annotated tags are object that are stored in the Git database. It contains information like the name, email, date, tag message etc. about the tag. It is generally recommended to use annotated tags so that all these information can be stored.
Creating a Tag
Git provides the ‘git tag’ command to work with tags.
To create an annotated tag we can use the following command:
git tag -a <tag_name> -m <tag_message>
To create a lightweight tag we need not provide any options since it doesn't store any information. We can use the below command to create a lightweight tag.
git tag <tag_name>
The image below shows how to create annotated tag. Note that we have used the 'git show' command to view a tag. Since it's an annotated tag it shows the tagger information, the date when the tag was created and the tag message along with the commit information at the tag location.
The image below shows how to create a lightweight tag. Also notice that the 'git show' command only shows the commit information at the tag location since it a lightweight tag.
We can use the 'git tag' command alone to list the available tags. Its usage can be noticed in the example images above.
All the tag we created were on the latest commit snapshot. We can also create a tag on the previous commit snapshots. We can use the commit checksum to do so as shown below:
git tag -a 946d1197c5717f4eecd26c921feccdeba91ed25c -m 'New Tag Location' git tag -a 946d119 -m 'new_tag' // A part of the checksum is also enough
Pushing Tags to Remote Repository
Tags are not send to the remote repository by the git push command. We need to explicitly send these tags to the remote server by using the following command:
git push origin <tagname>
git push origin v1.0
We can push all the tags at once by using the below command:
git push origin --tags
The concept of condition beans enables Spring to restrict the creation of any bean depending on the evaluation of a condition. These beans get created only when a preset condition is evaluated as true