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.
But the version name is "Tagged release 1.1.5
" according 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?
Will clone the repo and leave you on the tag you are interested in.
Documentation for 1.8.0 of git clone states.
For checking out only a given tag for deployment, I use e.g.:
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.
Working off of Peter Johnson's answer, I created a nice little alias for myself:
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.I do this is via the github API:
Checking out Tags
If you want to view the versions of files a tag is pointing to, you can do a git checkout, though this puts your repository in “detached HEAD” state, which has some ill side effects:
In “detached HEAD” state, if you make changes and then create a commit, the tag will stay the same, but your new commit won’t belong to any branch and will be unreachable, except for by the exact commit hash. Thus, if you need to make changes—say you’re fixing a bug on an older version, for instance—you will generally want to create a branch:
If you do this and make a commit, your version2 branch will be slightly different than your v2.0.0 tag since it will move forward with your new changes, so do be careful.
You can use git archive to download a tar ball for a given tag or commit id:
You can also export a zip archive of a tag.
List tags:
Export a tag:
Notes: