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 todoor
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