git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

Previous: Jeff King
Message 5 of 5 in “Cloning a remote tag without using git-fetch-pack directly?”
  1. Josh TriplettApr 19, 2011
  2. Jeff KingApr 20, 2011
  3. Josh TriplettApr 20, 2011
  4. Jeff KingApr 20, 2011
  5. Jonathan NiederApr 20, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.