Knowledge
How to checkout a Git tag
#Development
Checking out a tag puts you in a detached HEAD state, which is fine for inspecting a release but not for committing. If you want to make changes, create a branch from the tag.
Published by Mark van Eijk on June 23, 2026 · 1 minute read
- Checkout a tag
- You are now in detached HEAD
- Make changes from a tag: create a branch
- The tag is missing?
Checkout a tag
A tag points at a specific commit, usually a release. Check it out by name:
git checkout v1.2.0
To be unambiguous (in case a branch and a tag share a name), use the full ref:
git checkout tags/v1.2.0
You are now in detached HEAD
After checking out a tag, Git warns you that you are in a detached HEAD state. That means HEAD points directly at a commit instead of a branch. You can look around, build, and run the code, but any commits you make here are not on a branch and will be lost once you switch away.
Make changes from a tag: create a branch
If you need to work from a tagged release, for example to patch an old version, create a branch from the tag:
git checkout -b hotfix-1.2.0 v1.2.0
The modern equivalent uses git switch:
git switch --detach v1.2.0 # just inspect
git switch -c hotfix-1.2.0 v1.2.0 # branch off the tag
The tag is missing?
If git checkout v1.2.0 fails with pathspec ... did not match, your clone probably does not have the tag yet. Fetch tags from the remote:
git fetch --tags
List the tags you have to confirm the exact name:
git tag
Subscribe to our newsletter
Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!
Related articles
Install PHP memcached extension on macOS
Checking out a tag puts you in a detached HEAD state, which is fine for inspecting a release but not for committing. If you want to make changes, create a branch from the tag.
How to delete a local (and remote) Git branch
Checking out a tag puts you in a detached HEAD state, which is fine for inspecting a release but not for committing. If you want to make changes, create a branch from the tag.