Thread (5 messages) flat view 5 messages, 3 authors, 2016-06-15

Re: Cloning a remote tag without using git-fetch-pack directly?

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:51:04

Hi,

Some quick additional thoughts.

Jeff King wrote:
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help