Git - Clone branch at tag

To clone a specific tag from a GitHub repository, you can follow these steps:

1. Clone the repository

First, clone the repository without checking out the code by using the --no-checkout option:

git clone --no-checkout <repository-url>

2. Fetch the tags

Navigate to the cloned repository directory and fetch all tags:

cd <repository-name>
git fetch --tags

3. Checkout the specific tag

Finally, checkout the specific tag you want:

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

Example:

If you want to clone a repository and check out the tag v1.0, here’s how you would do it:

git clone --no-checkout https://github.com/user/repo.git
cd repo
git fetch --tags
git checkout tags/v1.0 -b v1.0-branch

This will clone the repository, fetch the tags, and check out the specified tag into a new branch called v1.0-branch.