GIT - Checkout TAGS

Introduction

It is quite common for developers to create tags in order to have reference points in their development. Sometimes the tags are used also to mark a version of the code.

It happen often that the code that we are maintained is used in other solutions as library.
And, of course, each solutions can use different version of our deployed code.

Real case

If different applications used different version of our deployed code (as library, for example), means that we have to maintain “all” the versions (maybe it is better to define from which version there is a maintenance support).

What we can do

In Git we can download a specific tag with this command:

$ git checkout tags/<tag> -b <branch>

Example:

$ git checkout tags/v1.0 -b v1.0-branch

Explanation

The git command checkout tags will download the codebase from the indicated tags (for example v1.0)
The parameter -b means : “Hey, put the downloaded files in this branch” and, after, GIT switched to the new branch (for example ‘v1.0-branch’)