# Local cache for git objects

4 messages from 2012-05-17 to 2012-05-17. Participants: Bartosz Gęza, Junio C Hamano.
Thread: https://gitlist.dev/t/30548

## Bartosz Gęza, 2012-05-17 20:06

Subject: Local cache for git objects
Message-ID: <CALnNMuHdNFktUkp+Vdc=ooTJ9ay_BJftAJ_toVaBDA5EOzt9ww@mail.gmail.com>
URL: https://gitlist.dev/e/CALnNMuHdNFktUkp%2BVdc%3DooTJ9ay_BJftAJ_toVaBDA5EOzt9ww%40mail.gmail.com

```
I'd like to speed up fetching objects from remote repositiories when creating
multiple clones on one or more machines in LAN.

I know it can be done by hand: git-fetch once and git-clone from local copy.
I think about adding new capability to upload-pack which would allow making
relay and object store. Client would supply url where "want"-ed objects should
be available.

Next I'd add config option for git-fetch with url of this cache.
fetch-pack would get refs from remote and request objects from cache.

I'm not sure if this hasn't been done.
Would such feature be included in git?

```

## Bartosz Gęza, 2012-05-17 20:36

Subject: Re: Local cache for git objects
Message-ID: <CALnNMuE=YQsXK-kiRUntNU_0s7s6ONgBk92dZN4UD0Va+qqF+Q@mail.gmail.com>
URL: https://gitlist.dev/e/CALnNMuE%3DYQsXK-kiRUntNU_0s7s6ONgBk92dZN4UD0Va%2BqqF%2BQ%40mail.gmail.com
In-Reply-To: <1337285744-ner-2739@calvin>

```
On Thu, May 17, 2012 at 10:15 PM, Tomas Carnecky
<tomas.carnecky@gmail.com> wrote:
> On Thu, 17 May 2012 22:06:51 +0200, Bartosz Gęza <bartoszgeza@gmail.com> wrote:
>> I'd like to speed up fetching objects from remote repositiories when creating
>> multiple clones on one or more machines in LAN.
> Does git clone --reference do what you want?

I didn't know about --reference, but that's not it.
I've tried it just now:

$ git init --bare reference.git
Initialized empty Git repository in /.../reference.git
$ git clone --reference ./reference.git/ git://someurl/foo.git foo
Cloning into 'foo'...
[...] (fetches whole pack)
$ git clone --reference ./reference.git/ git://someurl/foo.git foo2
Cloning into 'foo2'...
[...] (fetches whole pack again)

Reference is read only (?)
I'd like to set up one global cache repository and forget.
Later as I fetch any objects they are stored there for fast future access.

```

## Junio C Hamano, 2012-05-17 20:47

Subject: Re: Local cache for git objects
Message-ID: <xmqqk40a7cwi.fsf@junio.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqk40a7cwi.fsf%40junio.mtv.corp.google.com
In-Reply-To: <CALnNMuE=YQsXK-kiRUntNU_0s7s6ONgBk92dZN4UD0Va+qqF+Q@mail.gmail.com>

```
Bartosz Gęza <bartoszgeza@gmail.com> writes:

> Reference is read only (?)
> I'd like to set up one global cache repository and forget.
> Later as I fetch any objects they are stored there for fast future access.

Somebody needs to keep the "global cache" up to date, and that has to be
somebody who has access to cron(7) on your system, and you will be a
good candidate to do so.  So as part of the procedure to "set up one
global cache repository and forget (about it)", make a bare clone and
then set up a scheduled task to periodically "git fetch" from its
origin, and then you are pretty much done, no?

```

## Bartosz Gęza, 2012-05-17 21:11

Subject: Re: Local cache for git objects
Message-ID: <CALnNMuFtp0CoMkiP0W+6bOmd4Y6JD2b5HZuc3qfAuxiJjTcwEA@mail.gmail.com>
URL: https://gitlist.dev/e/CALnNMuFtp0CoMkiP0W%2B6bOmd4Y6JD2b5HZuc3qfAuxiJjTcwEA%40mail.gmail.com
In-Reply-To: <xmqqk40a7cwi.fsf@junio.mtv.corp.google.com>

```
On Thu, May 17, 2012 at 10:47 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
> Bartosz Gęza <bartoszgeza@gmail.com> writes:
>
> > Reference is read only (?)
> > I'd like to set up one global cache repository and forget.
> > Later as I fetch any objects they are stored there for fast future
> > access.
>
> Somebody needs to keep the "global cache" up to date, and that has to be
> somebody who has access to cron(7) on your system, and you will be a
> good candidate to do so.  So as part of the procedure to "set up one
> global cache repository and forget (about it)", make a bare clone and
> then set up a scheduled task to periodically "git fetch" from its
> origin, and then you are pretty much done, no?

That would work. It's a good practice for a single project with stable
dependencies.

My only concern is that it requires effort from user of the cache to
keep the list of tracked remotes up to date. After time user would
have to recall how to update the list or bother somebody who
remembers. I suppose that in a few months since set up it would only
include repositories that take over 5-10 minutes to fetch.

```
