* Quick way to clone exactly one branch
@ 2009-05-20 20:45 Avery Pennarun
2009-05-28 20:15 ` Jeff King
0 siblings, 1 reply; 4+ messages in thread
From: Avery Pennarun @ 2009-05-20 20:45 UTC (permalink / raw)
To: Git Mailing List
Hi all,
Is there a quick alternative to the following?
mkdir myproj
cd myproj
git init
git fetch git://whatever master
git checkout -b master FETCH_HEAD
Basically, the above is a lot like 'git clone' but only clones the
'master' branch. For really big projects with lots of junk in other
branches, the above can save a lot of bandwidth.
Also, if I were using git clone, I would often use --reference above.
I'm kind of afraid of explaining to a newbie that they should add an
entry to .git/objects/info/alternates after step 3.
Am I missing something obvious?
Have fun,
Avery
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Quick way to clone exactly one branch
2009-05-20 20:45 Quick way to clone exactly one branch Avery Pennarun
@ 2009-05-28 20:15 ` Jeff King
2009-05-28 20:26 ` Jakub Narebski
0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2009-05-28 20:15 UTC (permalink / raw)
To: Avery Pennarun; +Cc: Git Mailing List
On Wed, May 20, 2009 at 04:45:44PM -0400, Avery Pennarun wrote:
> Is there a quick alternative to the following?
>
> mkdir myproj
> cd myproj
> git init
> git fetch git://whatever master
> git checkout -b master FETCH_HEAD
>
> Basically, the above is a lot like 'git clone' but only clones the
> 'master' branch. For really big projects with lots of junk in other
> branches, the above can save a lot of bandwidth.
No, AFAIK there isn't a simpler way to do it. But it is something people
have asked about before, so I think it would be a nice addition.
You can't even use "git remote" because it doesn't allow you to tweak
the refspecs you add. To do it "just like clone" I think you would have
to:
git config remote.origin.url git://whatever
git config remote.origin.fetch refs/heads/master:refs/remotes/origin/master
It would be nice if that could be:
git remote add -b master origin git://whatever
and then make it available as:
git clone -b master git://whatever
Multiple "-b <branch>" options would generate refspecs to pull multiple
branches. You could even allow "git clone --refspec=<whatever>", but I
don't know what you would use that much flexibility for (and at that
point, you are probably comfortable enough to write the config
yourself).
-Peff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Quick way to clone exactly one branch
2009-05-28 20:15 ` Jeff King
@ 2009-05-28 20:26 ` Jakub Narebski
2009-05-28 20:32 ` Jeff King
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Narebski @ 2009-05-28 20:26 UTC (permalink / raw)
To: Jeff King; +Cc: Avery Pennarun, Git Mailing List
Jeff King <peff@peff.net> writes:
> On Wed, May 20, 2009 at 04:45:44PM -0400, Avery Pennarun wrote:
>
> > Is there a quick alternative to the following?
> >
> > mkdir myproj
> > cd myproj
> > git init
> > git fetch git://whatever master
> > git checkout -b master FETCH_HEAD
> >
> > Basically, the above is a lot like 'git clone' but only clones the
> > 'master' branch. For really big projects with lots of junk in other
> > branches, the above can save a lot of bandwidth.
>
> No, AFAIK there isn't a simpler way to do it. But it is something people
> have asked about before, so I think it would be a nice addition.
>
> You can't even use "git remote" because it doesn't allow you to tweak
> the refspecs you add. [...]
It doesn't? Strange, I thought that is what '-t <branch>' option
for "git remote add" for ;-))))
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Quick way to clone exactly one branch
2009-05-28 20:26 ` Jakub Narebski
@ 2009-05-28 20:32 ` Jeff King
0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2009-05-28 20:32 UTC (permalink / raw)
To: Jakub Narebski; +Cc: Avery Pennarun, Git Mailing List
On Thu, May 28, 2009 at 01:26:05PM -0700, Jakub Narebski wrote:
> > No, AFAIK there isn't a simpler way to do it. But it is something people
> > have asked about before, so I think it would be a nice addition.
> >
> > You can't even use "git remote" because it doesn't allow you to tweak
> > the refspecs you add. [...]
>
> It doesn't? Strange, I thought that is what '-t <branch>' option
> for "git remote add" for ;-))))
Oh, indeed. For some reason I thought that was about setting up tracking
for branches. So yes, Avery would be much better off in his example with
git remote add -t master origin git://whatever
But it would still be even nicer to have "clone -t master".
-Peff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-05-28 20:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-20 20:45 Quick way to clone exactly one branch Avery Pennarun
2009-05-28 20:15 ` Jeff King
2009-05-28 20:26 ` Jakub Narebski
2009-05-28 20:32 ` Jeff King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).