Download a Specific Tag with Git

Better Stack Team
Updated on June 24, 2024

To download a specific tag with Git, you can use the git checkout command along with the tag name. Here's how:

 
git checkout tags/<tag-name>

Replace <tag-name> with the name of the tag you want to download.

For example, if you want to download a tag named "v1.0.0", you would run:

 
git checkout tags/v1.0.0

This command checks out the specific tag, which means it puts your repository in a state that corresponds to the code at the time of that tag.

Note:

  • After running git checkout, you'll be in a "detached HEAD" state, meaning you're not on a branch but directly on the commit corresponding to the tag.
  • If you want to work with the code from the tag and make changes, you should create a new branch from the tag to work on:

     
    git checkout -b <new-branch-name> tags/<tag-name>
    

    Replace <new-branch-name> with the name you want to give to the new branch.