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.
clone -b "Tagged release 1.1.5" http://git.abc.net/git/abs.git my_abc
. This will only work if you don't have a branch with the same name of course (depending on your methodology, this may never happen). – RedGlyphgit checkout -b new-branch tag-name
. Now clone your new-branch. When ever we want we can delete the new-branch. – Kalidasan