How to checkout a git tag

How to checkout a git tag

Git tags are created to mark a release candidate. Because it points directly to a commit in the git history and will not change.

But sometimes we need to checkout a remote tag to our local. You can achieve this by fetching it from remote and checkout it as a branch on local.

Here is how we can achieve this.

Fetch git tags

The first thing you need is to fetch the git tag to your local. You can do this by using the git fetch command with --all and --tags arguments.

$ git fetch --all --tags


Checkout tag as a branch

The next step is to checkout a specific tag as a branch with git checkout command with the tag name and new branch name.

$ git checkout tags/<tag_name> -b <branch_name>

Now you can test the code from a tag on your local branch and make updates as well.

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
1 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.