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

Re: Elegant subdirectory checkout of remote-tracking branch?

From
Jeff King <peff@peff.net>
Date
Mar 2, 2013, 08:04 UTC
Message-ID
<20130302080425.GA22861@sigill.intra.peff.net>
In-Reply-To
<20130301152253.GA9312@odin.tremily.us>
On Fri, Mar 01, 2013 at 10:22:53AM -0500, W. Trevor King wrote:
Show 6 quoted lines
> These fail because I can't use a remote tracking branch as a
> source for the clone.  It should be possible to do:
> 
>   $ git clone --reference . --single-branch --branch todo git://git.kernel.org/pub/scm/git/git.git Meta
> 
> but that will require (I think) network access during a fetch.

Yes, it will. Junio mentioned already that for him, "Meta" is really a separate repository, and I think the simplest thing is to just treat it that way (that's how I handle my personal "meta" branch).

But if you really want to save the extra network round trip during a fetch, you can either:

  1. Just fetch from the surrounding repository using a custom refspec,
     like:
       git init Meta
       cd Meta
       git config add remote.origin.url ..
       git config add remote.origin.fetch \
         refs/remotes/origin/todo:refs/remotes/origin/todo
       git fetch
       git checkout todo
or
  2. Look into the git-new-workdir script in contrib/workdir, which lets
     you check out an alternate branch in a separate directory.

The latter would probably be the most seamless, but it's also the most likely to have bugs. :)

-Peff
Previous: Junio C Hamano
Message 3 of 3 in “Elegant subdirectory checkout of remote-tracking branch?”
  1. W. Trevor KingMar 1, 2013
  2. Junio C HamanoMar 1, 2013
  3. Jeff KingMar 2, 2013

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.