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

9 messages from 2007-10-10 to 2007-10-11. Participants: Joakim Tjernlund, Johannes Schindelin, Linus Torvalds, Andreas Ericsson.
Thread: https://gitlist.dev/t/10235

## Joakim Tjernlund, 2007-10-10 18:55

Subject: [FEATURE REQUEST] git clone, just clone selected branches?
Message-ID: <011401c80b6f$1a11d1f0$04ac10ac@Jocke>
URL: https://gitlist.dev/e/011401c80b6f%241a11d1f0%2404ac10ac%40Jocke

```
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, 2007-10-10 19:35

Subject: Re: [FEATURE REQUEST] git clone, just clone selected branches?
Message-ID: <Pine.LNX.4.64.0710102032330.4174@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0710102032330.4174%40racer.site
In-Reply-To: <011401c80b6f$1a11d1f0$04ac10ac@Jocke>

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

```

## Linus Torvalds, 2007-10-10 19:38

Subject: Re: [FEATURE REQUEST] git clone, just clone selected branches?
Message-ID: <alpine.LFD.0.999.0710101236350.20690@woody.linux-foundation.org>
URL: https://gitlist.dev/e/alpine.LFD.0.999.0710101236350.20690%40woody.linux-foundation.org
In-Reply-To: <011401c80b6f$1a11d1f0$04ac10ac@Jocke>

```


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, 2007-10-10 21:25

Subject: RE: [FEATURE REQUEST] git clone, just clone selected branches?
Message-ID: <011b01c80b84$222d1e70$04ac10ac@Jocke>
URL: https://gitlist.dev/e/011b01c80b84%24222d1e70%2404ac10ac%40Jocke
In-Reply-To: <Pine.LNX.4.64.0710102032330.4174@racer.site>

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

```

## Joakim Tjernlund, 2007-10-10 21:36

Subject: RE: [FEATURE REQUEST] git clone, just clone selected branches?
Message-ID: <011c01c80b85$a0d8d560$04ac10ac@Jocke>
URL: https://gitlist.dev/e/011c01c80b85%24a0d8d560%2404ac10ac%40Jocke
In-Reply-To: <alpine.LFD.0.999.0710101236350.20690@woody.linux-foundation.org>

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

```

## Johannes Schindelin, 2007-10-10 21:56

Subject: RE: [FEATURE REQUEST] git clone, just clone selected branches?
Message-ID: <Pine.LNX.4.64.0710102254340.4174@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0710102254340.4174%40racer.site
In-Reply-To: <011b01c80b84$222d1e70$04ac10ac@Jocke>

```
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, 2007-10-10 22:41

Subject: RE: [FEATURE REQUEST] git clone, just clone selected branches?
Message-ID: <011d01c80b8e$b0c0dc30$04ac10ac@Jocke>
URL: https://gitlist.dev/e/011d01c80b8e%24b0c0dc30%2404ac10ac%40Jocke
In-Reply-To: <Pine.LNX.4.64.0710102254340.4174@racer.site>

```
> -----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.

> 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
> 
> But maybe somebody else is interested enough to scratch your itch.
> 
> Ciao,
> Dscho
> 
> 
> 

```

## Johannes Schindelin, 2007-10-10 23:01

Subject: RE: [FEATURE REQUEST] git clone, just clone selected branches?
Message-ID: <Pine.LNX.4.64.0710110000420.4174@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0710110000420.4174%40racer.site
In-Reply-To: <011d01c80b8e$b0c0dc30$04ac10ac@Jocke>

```
Hi,

On Thu, 11 Oct 2007, Joakim Tjernlund wrote:

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

```

## Andreas Ericsson, 2007-10-11 09:18

Subject: Re: [FEATURE REQUEST] git clone, just clone selected branches?
Message-ID: <470DEA6E.5020107@op5.se>
URL: https://gitlist.dev/e/470DEA6E.5020107%40op5.se
In-Reply-To: <011c01c80b85$a0d8d560$04ac10ac@Jocke>

```
Joakim Tjernlund wrote:
>> -----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

```
