+7 votes
1 view
in Devops and Agile by (22.3k points)
edited by

I'm trying to figure out how I can download a particular tag of a Git repository - it's one version behind the current version.

I saw there was a tag for the previous version on the git web page, with the object name of something long hex number.

But the version name is "Tagged release 1.1.5" according to the site.

I tried a command like this (with names changed):

git clone http//git.abc.net/git/abc.git my_abc

And I did get something - a directory, a bunch of subdirectories, etc.

If it's the whole repository, how do I get at the version I'm seeking? If not, how do I download that particular version?

2 Answers

+7 votes
by (38.3k points)
edited ago by

For downloading a specific tag follow these commands

 git clone

It will help you to have the whole repository. After this, you can list the tags using 

git tag -l

create a new branch that will be helpful and checkout the tags using

 git checkout tags/<tag_name> -b <branch_name>

You can also check out tag using

git checkout tags/<tag_name>

But you will be on a branch named after the revision number of the tag.

For more information please go through the following tutorial to get more info about git:

+7 votes
by (45.5k points)

You need to clone your git repo and then cd into it, and checkout to a my-abc branch like this:

git clone http://git.abc.net/git/abc.git

cd abc

git checkout my_abc

OR

git clone http://git.abc.net/git/abc.git

cd abc

git checkout -b new_branch my_abc

The second variation establishes a new branch based on the tag, that allows you to avoid a 'detached HEAD'. Every git repo contains the entire revision history, so cloning the repo gives you access to the latest commit, plus everything that came before, including the tag you're looking for. 

...