git clone - Download a specific tag with Git

ID : 432

viewed : 127

Tags : gitgit-clonegit-taggit

Top 5 Answer for git clone - Download a specific tag with Git

vote vote


$ 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> 
vote vote


git clone --branch my_abc 

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.

vote vote


For checking out only a given tag for deployment, I use e.g.:

git clone -b 'v2.0' --single-branch --depth 1 

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.


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.

vote vote


I'm not a git expert, but I think this should work:

git clone cd abc git checkout my_abc  


git clone cd abc git checkout -b new_branch my_abc 

The second variation establishes a new branch based on the tag, which lets you avoid a 'detached HEAD'. (git-checkout manual)

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.

vote vote


You can use git archive to download a tar ball for a given tag or commit id:

git archive --format=tar --remote=[hostname]:[path to repo] [tag name] > tagged_version.tar 

You can also export a zip archive of a tag.

  1. List tags:

    git tag  0.0.1 0.1.0 
  2. Export a tag:

    git archive -o /tmp/ --prefix=my-repo-0.1.0/ 0.1.0 
  3. Notes:

    • You do not need to specify the format. It will be picked up by the output file name.
    • Specifying the prefix will make your code export to a directory (if you include a trailing slash).

Top 3 video Explaining git clone - Download a specific tag with Git