Friday, June 24, 2016

Unleashing the Git - part 4 - Git Tagging

Tagging comes very handy in managing a repository. Tags and branches are similar concepts. But tags are read only. There are two types of tags. 1) Lightweight 2) Annotated
$ git tag Basic_Features    // Creates a Basic_Features tag.
$ git tag            // Shows available tags
Basic_Features
$ git show Basic_Features   // Which show the details of the commit on which Basic_Feature tag is added
$ git tag beta1 HEAD^ // Creates a tag from next to last commit
Earlier I showed how to check out code with commit id. We can also use the tags to checkout code of a particular stage using the following command.
$ git checkout Basic_Feature
All of the above are lightweight/unannotated tag. Creating an annotated tag is as simple as creating lightweight tag as below,
$ git tag -a Basic_Messaging_Annotated -m "Annotated tag at Messaging"
$ git show Basic_Messaging_Annotated   // this will provide the details of the tagger as well.
Deleting a tag is same for both tag types.
$ git tag -d Basic_Messaging_Annotated  // Deletes the annotated tag we created.
$ git push origin v1.0 // Push local tag v1.0 to remote origin.
$ git push --tags origin // Push all the local tags to remote origin
$ git fetch --tags origin // fetches all the remote origins tags to local repository. Note: If you have a local tag with same name as a remote tag, it'll be overwritten

No comments:

Post a Comment