Skip to main content

How to Checkout Tags in Git

Short answer

To check out a specific tag in Git, run git checkout <tag-name>, which puts your repository into 'detached HEAD' state pointing to the commit the tag references. In detached HEAD you can explore the project as it was at that tagged version, compile the code, or run tests, but new commits will not belong to any branch and risk being lost when you switch away. If you need to make changes starting from a tag — for example to create a hotfix for a release — immediately create a branch: git checkout -b <branch-name> <tag-name>. To list all available tags before checking one out, run git tag or use git tag -l "v1.*" to filter by a pattern. Tags are commonly used to mark release points such as v1.0.0, making git checkout <tag> a reliable way to reproduce the exact state of a specific release.

In Git, tags are used to mark specific commits, e.g. release versions. This is also the big difference between tags and branches: while a branch pointer moves when additional commits are made, a tag remains fixed on the specified revision.

In this short article, we'll now take a look at how to checkout a tag in Git.

The Git Cheat Sheet

No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!

Free. We email you a ZIP with our cheat sheets.


Using git checkout with Tags

The well-known git checkout command is mainly used for handling branches, but it can also be used for tags:

git checkout v2.0

By providing the tag's name as a parameter, Git will checkout that tag's revision.

However, this might not be what you actually wanted, because your local repository is now in a "Detached HEAD" state! This means that the HEAD pointer is currently NOT on a branch, but on a specific revision. If you create additional commits in this state, they will not be associated with any branch (because no branch is currently checked out)! In such a scenario, it's very easy to lose your new commits!

It's much more likely that would like to create a new branch, based on the tag's commit. You can simply add the -b flag and provide a name for the new branch:

git checkout -b new-branch v2.0

You will then have a brand new branch named "new-branch" that's based on the revision that the "v2.0" tag points at.

No Command Line Needed

Checking Out Tags in Tower

In case you are using the Tower Git client, you can simply drag & drop the tag in Tower's sidebar to create a new branch from it and check it out:

Free download

Download the Cheat Sheet

Get 18 of our most popular Cheat Sheets in one handy ZIP!