Re: Cloning a remote tag without using git-fetch-pack directly?
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Apr 20, 2011, 07:40 UTC
- Message-ID
- <20110420073955.GA809@elie>
- In-Reply-To
- <20110420062653.GE28597@sigill.intra.peff.net>
Hi,
Some quick additional thoughts.
Jeff King wrote:
Show 10 quoted lines
> To clone a subset of a repository, you have to do the init+fetch trick, > as you did above. If you want the configuration set up by clone, you > can do that, too, with "git config". So the equivalent commands to the > clone you want are: > > git init linux-2.6 > cd linux-2.6 > git config remote.origin.url /home/josh/src/linux-2.6 > git config remote.origin.fetch refs/tags/v2.6.12 > git fetch origin
Someone fetching v2.6.12 to build on it today is probably not planning to run "git fetch origin" to fetch the same tag tomorrow. So
git init linux-2.6 cd linux-2.6 git remote add origin ~/src/linux-2.6 git fetch origin refs/tags/v2.6.12
or even "...; git fetch ~/src/linux-2.6 refs/tags/v2.6.12" could be closer to what is needed.
If for some reason you do want to track how the remote v2.6.12 tag evolves, "git remote" has a funny way to do that:
git remote add --mirror=fetch -ttags/v2.6.12 origin ~/src/linux.2.6
The documentation calls the argument to -t "<branch>", but in mirror mode it is actually a refspec relative to refs/.
With luck (depending on what you are looking to do), git-new-workdir[1] or "git archive --remote" could also be helpful.
Regards, Jonathan
[1] with the usual avoidable caveats described at https://git.wiki.kernel.org/index.php/SoC2011Ideas#Multiple_work_trees