threads / discuss / 10235

[FEATURE REQUEST] git clone, just clone selected branches?

Subject: [FEATURE REQUEST] git clone, just clone selected branches?

## tl;dr

9 messages between Oct 10, 2007 and Oct 11, 2007.

replies: 8people: 4as markdown or json

Joakim Tjernlund· Oct 10, 2007, 18:55 UTC · lore
To my knowlede a git clone always clones all branches from the remote repo.
I would like the possibly to clone selected branches, like
 git clone <repo URL> -b master -b upstream
which will only fetch the master and upstream branch.

I know I can use git remote to do this, but it is a bit clumsy when starting a new repo.

What do you think?
 Jocke
Johannes Schindelin· Oct 10, 2007, 19:35 UTC · re: Joakim Tjernlund · lore

Re: [FEATURE REQUEST] git clone, just clone selected branches?

Hi,
On Wed, 10 Oct 2007, Joakim Tjernlund wrote:
Show 7 quoted lines
> To my knowlede a git clone always clones all branches from the remote 
> repo. I would like the possibly to clone selected branches, like
>  git clone <repo URL> -b master -b upstream
> which will only fetch the master and upstream branch.
> 
> I know I can use git remote to do this, but it is a bit clumsy when 
> starting a new repo.

This is why I suggest: since it is an itch of yours, just fix it. You are in the prime position to know when you're satisfied.

As a hint how to start: Junio dreamt of a git-clone which is a tiny wrapper around git-fetch and git-remote.

So you could start by writing a script which would be a replacement for git-clone.sh, and there you can also include the support for -b that you would like so much.

It would be nice, though, to keep this in separate patches, which you then submit to this list.

Thank you, Dscho

Joakim Tjernlund· Oct 10, 2007, 21:25 UTC · re: Johannes Schindelin · lore

RE: [FEATURE REQUEST] git clone, just clone selected branches?

Show 40 quoted lines
> -----Original Message-----
> From: Johannes Schindelin [mailto:Johannes.Schindelin@gmx.de] 
> Sent: den 10 oktober 2007 21:35
> To: Joakim Tjernlund
> Cc: git@vger.kernel.org
> Subject: Re: [FEATURE REQUEST] git clone, just clone selected 
> branches?
> 
> Hi,
> 
> On Wed, 10 Oct 2007, Joakim Tjernlund wrote:
> 
> > To my knowlede a git clone always clones all branches from 
> the remote 
> > repo. I would like the possibly to clone selected branches, like
> >  git clone <repo URL> -b master -b upstream
> > which will only fetch the master and upstream branch.
> > 
> > I know I can use git remote to do this, but it is a bit clumsy when 
> > starting a new repo.
> 
> This is why I suggest: since it is an itch of yours, just fix 
> it.  You are 
> in the prime position to know when you're satisfied.
> 
> As a hint how to start: Junio dreamt of a git-clone which is a tiny 
> wrapper around git-fetch and git-remote.
> 
> So you could start by writing a script which would be a 
> replacement for 
> git-clone.sh, and there you can also include the support for 
> -b that you 
> would like so much.
> 
> It would be nice, though, to keep this in separate patches, 
> which you then 
> submit to this list.
> 
> Thank you,
> Dscho

Thank you for these words of visdom, I should know better than to throw out ideas like this. Next time I have an suggestion I will think long and hard about it before posting again.

 Jocke 
Johannes Schindelin· Oct 10, 2007, 21:56 UTC · re: Joakim Tjernlund · lore

RE: [FEATURE REQUEST] git clone, just clone selected branches?

Hi,
On Wed, 10 Oct 2007, Joakim Tjernlund wrote:
> I should know better than to throw out ideas like this. Next time I have 
> an suggestion I will think long and hard about it before posting again.
Hey, it was just a try.

Personally, I am not interested in the feature _you_ asked for, but I thought it might be pretty easy for you to rewrite git-clone.sh to take advantage of git-fetch and git-remote, and that your desired feature would be easier to add then. So easy that the whole thing would have taken you all of an hour or so.

But maybe somebody else is interested enough to scratch your itch.

Ciao, Dscho

Joakim Tjernlund· Oct 10, 2007, 22:41 UTC · re: Johannes Schindelin · lore

RE: [FEATURE REQUEST] git clone, just clone selected branches?

Show 13 quoted lines
> -----Original Message-----
> From: Johannes Schindelin [mailto:Johannes.Schindelin@gmx.de] 
> 
> Hi,
> 
> On Wed, 10 Oct 2007, Joakim Tjernlund wrote:
> 
> > I should know better than to throw out ideas like this. 
> Next time I have 
> > an suggestion I will think long and hard about it before 
> posting again.
> 
> Hey, it was just a try.
Some people might get scared away from such tries
> 
> Personally, I am not interested in the feature _you_ asked for, but I 
NP, if it only me that is interested then this is probably not such a good idea.
Show 7 quoted lines
> thought it might be pretty easy for you to rewrite 
> git-clone.sh to take 
> advantage of git-fetch and git-remote, and that your desired 
> feature would 
> be easier to add then.  So easy that the whole thing would 
> have taken you 
> all of an hour or so.

Well, now I had to take a look and I think you are overestimating my capabilities :) It is a 12KB script full of git-plumbing I have never used, nor do I do sh scripts well. It might be an hour for you, but I would probably have to spend the whole day :)

 Jocke
Show 8 quoted lines
> 
> But maybe somebody else is interested enough to scratch your itch.
> 
> Ciao,
> Dscho
> 
> 
> 
Johannes Schindelin· Oct 10, 2007, 23:01 UTC · re: Joakim Tjernlund · lore

RE: [FEATURE REQUEST] git clone, just clone selected branches?

Hi,
On Thu, 11 Oct 2007, Joakim Tjernlund wrote:
Show 12 quoted lines
> > -----Original Message-----
> > From: Johannes Schindelin [mailto:Johannes.Schindelin@gmx.de] 
> > 
> > thought it might be pretty easy for you to rewrite git-clone.sh to 
> > take advantage of git-fetch and git-remote, and that your desired 
> > feature would be easier to add then.  So easy that the whole thing 
> > would have taken you all of an hour or so.
> 
> Well, now I had to take a look and I think you are overestimating my 
> capabilities :) It is a 12KB script full of git-plumbing I have never 
> used, nor do I do sh scripts well. It might be an hour for you, but I 
> would probably have to spend the whole day :)

Heh. git-clone is pretty crowded. But it predates git-remote. And I have a hunch that git-clone will be a trivial script when it calls git-remote and the git-fetch.

Ciao, Dscho

Linus Torvalds· Oct 10, 2007, 19:38 UTC · re: Joakim Tjernlund · lore

Re: [FEATURE REQUEST] git clone, just clone selected branches?

On Wed, 10 Oct 2007, Joakim Tjernlund wrote:
> 
> I know I can use git remote to do this, but it is a bit clumsy 
> when starting a new repo.
How about just
	git init
	.. set up remote tracking info in .git/config ..
	git fetch remote
which should do what you want.
		Linus
Joakim Tjernlund· Oct 10, 2007, 21:36 UTC · re: Linus Torvalds · lore

RE: [FEATURE REQUEST] git clone, just clone selected branches?

Show 24 quoted lines
> -----Original Message-----
> From: Linus Torvalds [mailto:torvalds@linux-foundation.org] 
> Sent: den 10 oktober 2007 21:38
> To: Joakim Tjernlund
> Cc: git@vger.kernel.org
> Subject: Re: [FEATURE REQUEST] git clone, just clone selected 
> branches?
> 
> 
> 
> On Wed, 10 Oct 2007, Joakim Tjernlund wrote:
> > 
> > I know I can use git remote to do this, but it is a bit clumsy 
> > when starting a new repo.
> 
> How about just
> 
> 	git init
> 	.. set up remote tracking info in .git/config ..
> 	git fetch remote
> 
> which should do what you want.
> 
> 		Linus
>From git remote man page:
 o  Imitate git clone but track only selected branches
          $ mkdir project.git
          $ cd project.git
          $ git init
          $ git remote add -f -t master -m master origin git://example.com/git.git/
          $ git merge origin

yes, this does the trick too but that is more to type so I thought it would be simpler if I could just tell git clone which branches I want. Now, this isn't a killer feature to me so if you don't like it, I good with that too.

 Jocke
Andreas Ericsson· Oct 11, 2007, 09:18 UTC · re: Joakim Tjernlund · lore

Re: [FEATURE REQUEST] git clone, just clone selected branches?

Joakim Tjernlund wrote:
Show 37 quoted lines
>> -----Original Message-----
>> From: Linus Torvalds [mailto:torvalds@linux-foundation.org] 
>> Sent: den 10 oktober 2007 21:38
>> To: Joakim Tjernlund
>> Cc: git@vger.kernel.org
>> Subject: Re: [FEATURE REQUEST] git clone, just clone selected 
>> branches?
>>
>>
>>
>> On Wed, 10 Oct 2007, Joakim Tjernlund wrote:
>>> I know I can use git remote to do this, but it is a bit clumsy 
>>> when starting a new repo.
>> How about just
>>
>> 	git init
>> 	.. set up remote tracking info in .git/config ..
>> 	git fetch remote
>>
>> which should do what you want.
>>
>> 		Linus
> 
> From git remote man page:
>  o  Imitate git clone but track only selected branches
> 
>           $ mkdir project.git
>           $ cd project.git
>           $ git init
>           $ git remote add -f -t master -m master origin git://example.com/git.git/
>           $ git merge origin
> 
> yes, this does the trick too but that is more to type so I thought
> it would be simpler if I could just tell git clone which branches I want.
> Now, this isn't a killer feature to me so if you don't like it, I good
> with that too.
> 
Well, that's how git-clone should probably look, now that git-remote exists.
-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

← back to recent threads