On Git, it’s pretty common for users to create tags to have reference points in their development. Tags are also Git objects, stating that they can be checked out exactly as a user checkout commit or branch. Developers create them for releasing the version. However, sometimes it can be required to download the tag from the remote repository. To do so, the “$ git clone –branch <tag-name> <remote-url>” command can be used.
This blog will describe downloading a specific tag with Git from a remote repository.
How to Download a Specific Tag With Git?
To download a specific tag from the remote repository with Git, first, navigate to the Git particular local directory. Then, open the remote hosting service, view the existing remote tags, and select one of them. Next, copy the remote repository HTTPS URL. To download the specific remote tag, execute the “$ git clone –branch <tag-name> <remote-url>” command and check the tag list. If you want to switch to it, run the “$ git checkout <tag-name>” command.
Let’s move forward and implement the above-listed scenario!
Step 1: Move to Local Repository
First, execute the “cd” command and navigate to the Git local repository:
Step 2: Select Tag From Remote Repository
Next, go to the GitHub hosting service and open the remote repository. Click on the below-highlighted button to view the list of remote existing tags and select one of them:
Step 3: Copy Remote URL
Next, click on the “Code” button and copy the remote HTTPS URL:
Step 4: Clone Remote Repository
Now, execute the “git clone” command along with the “–branch” parameter and select the tag to connect the remote repository with the local machine:
Step 5: List Tags
After cloning the specific tag, run the “git tag” command with the “-l” option to view the list of cloned tags:
According to the below-listed output, the specified tag is successfully downloaded from remote to local:
Step 6: Checkout Tag
Checkout to downloaded remote tag by executing the “git checkout” command with the tag:
That’s it! We have described the method to download a specific tag with Git from a remote repository.
Conclusion
To download a specific tag with Git, first, move to the desired Git directory. After that, go to the browser and open the GitHub remote hosting service. Then, check the existing remote tags and select one of them. Copy the remote repository HTTPS URL. Next, download the specific remote tag through the “$ git clone –branch <tag-name> <remote-url>” command. Check the tag list and execute the “$ git checkout <tag-name>” to switch to it. This blog demonstrated downloading a specific tag with Git from a remote repository.