Download a specific tag with Git
$ git clone
will give you the whole repository.
After the clone, you can list the tags with $ git tag -l
and then checkout a specific tag:
$ git checkout tags/<tag_name>
Even better, checkout and create a branch (otherwise you will be on a branch named after the revision number of tag):
$ git checkout tags/<tag_name> -b <branch_name>
For checking out only a given tag for deployment, I use e.g.:
git clone -b 'v2.0' --single-branch --depth 1 https://github.com/git/git.git
This seems to be the fastest way to check out code from a remote repository if one has only interest in the most recent code instead of in a complete repository. In this way, it resembles the 'svn co' command.
Note: Per the Git manual, passing the --depth
flag implies --single-branch
by default.
--depth
Create a shallow clone with a history truncated to the specified number of commits. Implies --single-branch unless --no-single-branch is given to fetch the histories near the tips of all branches. If you want to clone submodules shallowly, also pass --shallow-submodules.
git clone --branch my_abc http://git.abc.net/git/abc.git
Will clone the repo and leave you on the tag you are interested in.
Documentation for 1.8.0 of git clone states.
--branch can also take tags and detaches the HEAD at that commit in the resulting repository.