# Wishlist: git fetch --reference

4 messages from 2014-08-22 to 2014-08-22. Participants: Howard Chu, Jeff King, Dennis Kaarsemaker.
Thread: https://gitlist.dev/t/37396

## Howard Chu, 2014-08-22 02:57

Subject: Wishlist: git fetch --reference
Message-ID: <53F6B1AB.3030706@symas.com>
URL: https://gitlist.dev/e/53F6B1AB.3030706%40symas.com

```
I maintain multiple copies of the same repo because I keep each one checked 
out to different branch/rev levels. It would be nice if, similar to clone 
--reference, we could also use git fetch --reference to reference a local repo 
when doing a fetch to pull in updates.

-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

```

## Jeff King, 2014-08-22 04:20

Subject: Re: Wishlist: git fetch --reference
Message-ID: <20140822042057.GD27992@peff.net>
URL: https://gitlist.dev/e/20140822042057.GD27992%40peff.net
In-Reply-To: <53F6B1AB.3030706@symas.com>

```
On Thu, Aug 21, 2014 at 07:57:47PM -0700, Howard Chu wrote:

> I maintain multiple copies of the same repo because I keep each one checked
> out to different branch/rev levels. It would be nice if, similar to clone
> --reference, we could also use git fetch --reference to reference a local
> repo when doing a fetch to pull in updates.

I think it is just spelled:

  echo $reference_repo >>.git/objects/info/alternates
  git fetch

We need "--reference" with clone because that first line needs to happen
after clone runs "git init" but before it runs "git fetch". And if you
cloned with --reference, of course, the alternates file remains and
further fetches will automatically use it.

-Peff

```

## Howard Chu, 2014-08-22 05:25

Subject: Re: Wishlist: git fetch --reference
Message-ID: <53F6D44E.7040907@symas.com>
URL: https://gitlist.dev/e/53F6D44E.7040907%40symas.com
In-Reply-To: <20140822042057.GD27992@peff.net>

```
Jeff King wrote:
> On Thu, Aug 21, 2014 at 07:57:47PM -0700, Howard Chu wrote:
>
>> I maintain multiple copies of the same repo because I keep each one checked
>> out to different branch/rev levels. It would be nice if, similar to clone
>> --reference, we could also use git fetch --reference to reference a local
>> repo when doing a fetch to pull in updates.
>
> I think it is just spelled:
>
>    echo $reference_repo >>.git/objects/info/alternates
>    git fetch
>
> We need "--reference" with clone because that first line needs to happen
> after clone runs "git init" but before it runs "git fetch". And if you
> cloned with --reference, of course, the alternates file remains and
> further fetches will automatically use it.

Aha, thanks, hadn't realized that. Just checked and yes, the alternates file 
is already set in all of these different copies.

-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

```

## Dennis Kaarsemaker, 2014-08-22 07:01

Subject: Re: Wishlist: git fetch --reference
Message-ID: <1408690918.5586.3.camel@seahawk>
URL: https://gitlist.dev/e/1408690918.5586.3.camel%40seahawk
In-Reply-To: <53F6B1AB.3030706@symas.com>

```
On do, 2014-08-21 at 19:57 -0700, Howard Chu wrote:
> I maintain multiple copies of the same repo because I keep each one checked 
> out to different branch/rev levels. It would be nice if, similar to clone 
> --reference, we could also use git fetch --reference to reference a local repo 
> when doing a fetch to pull in updates.

Alternatively, you can use Duy's multiple-work-trees patches to safely
make multiple checkouts of one repository. These patches are in next.  
-- 
Dennis Kaarsemaker
http://www.kaarsemaker.net

```
