Working With Git Release Tags

Introduction

Generally we creates Git Tags to manage and keep on track of the special releases (Environment wise Releases such as UAT, Production etc.) of a given product. Firstly let's have a clear idea about what is a Release? and what is a Tag in Git and the purpose of creating Git Tags.

What is a Release?

Releases are specific points (Release Points) of the code repository where the code seems to be in a stable version and suits for a new deployment.
Releases of any product are generally look like as below.
(v1.0, v1.1, v1.2, ...)

Consider that the current application stable version is v1.1.0. So, here are some different scenarios and different versioning formats which may possible.

1. Production Release version for Bug Fixing: v1.1.1
2. Production Release version for new URS: v1.2.0
3. Production Release version for Huge Change such as a Revamp: v2.0.0

What are GIT Tags?

We use Tags to create specific points (Release Points) in history for your project repository using the Git or any other VCS you may use. Basically the purpose of creating tags are for the easiness of keep on track about the release versions of a given product from its very beginning to the end.


What is the purpose of Git Tags?

As we mention above, the purposes of creating Git Tags are as follows:

1. To mark release points for the code repository.
        When you want to create a release point for a stable version of the code.
        
2. To create historic restore points.
        When you want to create a historic point for your code that you may refer at future for any purpose of         restoring or compare changes with current version.

How to create Tags in Git

Now let's dig in to our main topic of how to create Git Tags and how to deal with them.


1. Firstly you must checkout to the branch you want to create the tag. Most probably it is a master branch     or specific Release Branch. Generally Production Release Tags are created using master branch and           other UAT Release Tags are created using relevant Release Branches.

    Command Syntax: git checkout <branch name>

    Eg: git checkout master


2. Create the Git Tag with a specific name.

  • Create Git Tag just with name
            Command Syntax: git tag <tag name>
            Eg: git tag v1.0
  • Create an Annotated Git Tag 
            Command Syntax: git tag -a <tag name> -m <tag message description>
            Eg: git tag -a v1.1 -m "tag for release version 1.1"


3. You can view all the currently created Git Tags executing the following commands.
  • View all currently available Git Tags.
            Command: git tag
  • View a specific detailed description of a given Git Tag.
            Command Syntax: git show <tag name>
            Eg:- git show v1.0
  •  View all available Git Tags starts with given pattern.
            Command Syntax: git tag -l "<starting pattern of the tags>.*"
            Eg: git tag -l "v1.*"

4. Push Locally Created Tags to the Remote Repository
  •  Push just a specifically created git tag to the remote.
            Command Syntax: git push origin <tag name>
            Eg: git push origin v1.0
  • Or you can just add all the locally created tags to the remote at once using the below commands.
            Command Syntax: 
    • git push origin --tags
    • git push --tags
5. Delete a specific tag ready created. (only when an urgent scenario)
  • Delete a specific git tag which is already created from the local repository.
            Command Syntax: git tag -d <tag name> or git tag --delete <tag-name>

            Eg: 
    • git tag -d v1.0
    • git tag --delete v1.0

  • Delete a specific git tag which is already created from the remote repository by executing the following commands.
            Command Syntax: git push origin -d <tag name>, git push origin --delete <tag name>, or git push origin :<tag name>

            Eg:
    • git push origin -d v1.0
    • git push origin --delete v1.0
    • git push origin :v1.0
  • Delete a specific a set of git tags at once in a single command.
    • Delete from the local repository:
      • Command Syntax: git tag -d <tag name1> <tag name2>
                            Eg: git tag -d v1.0 v1.1
    • Delete from the remote repository:
      • Command  Syntax: git push origin -d <tag name1> <tag name2>
                            Eg: git push origin -d v1.0 v1.1 
                            

Buy website traffic cheap

Post a Comment

0 Comments