Download a specific tag with Git

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 object name of something long hex number.

  • git smudge/clean filter between branches
  • How to include other folders within the @INC for Perl? (Was: `Can't locate in @INC` for svn2git)
  • Why “git push helloworld +master:master” instead of just “git push helloworld”?
  • Git shared repository doesn't work as 'shared'
  • How can I get file binary data out of Git repository using LibGit2Sharp?
  • Why doesn't `git checkout` automatically do `git submodule update --recursive`?
  • But the version name is “Tagged release 1.1.5” according the site.

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

    git clone 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?

  • Tortoise GIT: go back to previous version
  • Github/Cygwin error: cygheap base mismatch detected
  • git apply : error trailing whitespace
  • git flow branching model… how does 'qa' branch fit in, with jenkins auto deploy?
  • Git - Can't change branch
  • How to list all tags that contain a commit?
  • 14 Solutions collect form web for “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>

    git clone --branch my_abc

    Will clone the repo and leave you on the tag you are interested in.

    Documentation for of git clone states.

    –branch can also take tags and detaches the HEAD at that commit in the resulting repository.

    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.

    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
    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).

    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.

    Use the --single-branch switch (available as of Git 1.7.10). The syntax is:

    git clone -b <tag_name> --single-branch <repo_url> [<dest_dir>] 

    For example:

    git clone -b 'v1.9.5' --single-branch git-1.9.5

    The benefit: Git will receive objects and (need to) resolve deltas for the specified branch/tag only – while checking out the exact same amount of files! Depending on the source repository, this will save you a lot of disk space. (Plus, it’ll be much quicker.)

    first fetch all the tags in that specific remote

    git fetch <remote> 'refs/tags/*:refs/tags/*'

    or just simply type

    git fetch <remote>

    Then check for the available tags

    git tag -l

    then switch to that specific tag using below command

    git checkout tags/<tag_name>

    Hope this will helps you!

    If your tags are sortable using the linux sort command, use this:

    git tag | sort -n | tail -1

    eg. if git tag returns:


    git tag | sort -n | tail -1 will output:


    git tag | sort -n | tail -2 | head -1 will output:


    (because you asked for the second most recent tag)

    to checkout the tag, first clone the repo, then type:

    git checkout v1.0.4

    ..or whatever tag you need.

    I checked the git checkout documentation, it revealed one interesting thing:

    git checkout -b <new_branch_name> <start_point>
    , where the <start_point> is the name of a commit
    at which to start the new branch;
    Defaults to HEAD

    So we can mention the tag name( as tag is nothing but a name of a commit) as, say:

    >> git checkout -b 1.0.2_branch 1.0.2
    later, modify some files
    >> git push –tags

    P.S: In Git, you can’t update a tag directly(since tag is just a label to a commit), you need to checkout the same tag as a branch and then commit to it and then create a separate tag.

    git fetch <gitserver> <remotetag>:<localtag>


    I just did this. First I made sure I knew the tag name spelling.

    git ls-remote --tags gitserver; : or origin, whatever your remote is called

    This gave me a list of tags on my git server to choose from.
    The original poster already knew his tag’s name so this step is not necessary for everyone.
    The output looked like this, though the real list was longer.

    8acb6864d10caa9baf25cc1e4857371efb01f7cd    refs/tags/v5.2.2.2
    f4ba9d79e3d760f1990c2117187b5010e92e1ea2    refs/tags/v5.2.3.1
    8dd05466201b51fcaf4ca85897347d82fcb29518    refs/tags/Fix_109
    9b5087090d9077c10ba22d99d5ce90d8a45c50a3    refs/tags/Fix_110

    I picked the tag I wanted and fetched that and nothing more as follows.

    git fetch gitserver Fix_110

    I then tagged this on my local machine, giving my tag the same name.

    git tag Fix_110 FETCH_HEAD

    I didn’t want to clone the remote repository as other people have suggested doing, as the project I am working on is large and I want to develop in a nice clean environment. I feel this is closer to the original questions “I’m trying to figure out how do download A PARTICULAR TAG” than the solution which suggests cloning the whole repository. I don’t see why anyone should have to have a copy of Windows NT and Windows 8.1 source code if they want to look at DOS 0.1 source code (for example).

    I also didn’t want to use CHECKOUT as others have suggested. I had a branch checked out and didn’t want to affect that. My intention was to fetch the software I wanted so that I could cherry-pick something and add that to my development.

    There is probably a way to fetch the tag itself rather than just a copy of the commit that was tagged. I had to tag the fetched commit myself. EDIT: Ah yes, I have found it now.

    git fetch gitserver Fix_110:Fix_110

    Where you see the colon, that is remote-name:local-name and here they are the tag names. This runs without upsetting the working tree etc. It just seems to copy stuff from the remote to the local machine so you have your own copy.

    git fetch gitserver --dry-run Fix_110:Fix_110

    with the –dry-run option added will let you have a look at what the command would do, if you want to verify its what you want. So I guess a simple

    git fetch gitserver remotetag:localtag

    is the real answer.


    A separate note about tags … When I start something new I usually tag the empty repository after git init, since

    git rebase -i XXXXX 

    requires a commit, and the question arises “how do you rebase changes that include your first software change?” So when I start working I do

    git init
    touch .gitignore
    [then add it and commit it, and finally]
    git tag EMPTY

    i.e. create a commit before my first real change and then later use

    git rebase -i EMPTY 

    if I want to rebase all my work, including the first change.

    Working off of Peter Johnson’s answer, I created a nice little alias for myself:

    alias gcolt="git checkout \`git tag | sort -V | tail -1\`"

    aka ‘git checkout latest tag’.

    This relies on the GNU version of sort, which appropriately handles situations like the one lOranger pointed out:


    If you’re on a mac, brew install coreutils and then call gsort instead.


    git clone -b <name_of_the_tag> <repository_url> <destination>

    I do this is via the github API:

    curl -H "Authorization: token %(access_token)s" -sL -o /tmp/repo.tar.gz "" ;\
    tar xfz /tmp/repo.tar.gz -C /tmp/repo --strip-components=1 ; \

    Clone with -b option also helps:
    git clone -b v2.0

    The following post uses the above option to download mvc:

    Git Baby is a git and github fan, let's start git clone.