DEV Community

Cover image for How to checkout a git tag?
NoviceDev
NoviceDev

Posted on • Originally published at novicedev.com

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.

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
Enter fullscreen mode Exit fullscreen mode

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>
Enter fullscreen mode Exit fullscreen mode

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

Original Post: https://www.novicedev.com/blog/how-checkout-git-tag

Top comments (1)

Collapse
 
sso profile image
Sall

Nice post, if need some ideas:
dev.to/sso/are-you-a-writer-b7m