# Produce contents of index with existing directory as cache

5 messages from 2017-08-30 to 2017-08-31. Participants: Florian Weimer, David Lloyd.
Thread: https://gitlist.dev/t/46686

## Florian Weimer, 2017-08-30 14:11

Subject: Produce contents of index with existing directory as cache
Message-ID: <5a9e4efd-8c48-487e-4a9f-9362a944c992@redhat.com>
URL: https://gitlist.dev/e/5a9e4efd-8c48-487e-4a9f-9362a944c992%40redhat.com

```
Is there a variant of “git checkout-index” which will produce the
existing index contents, like “git checkout-index” would do with an
empty directory, but can reuse an existing directory tree, to avoid
writing all files from scratch?

I'm writing some analysis scripts which need to change a checked-out
working tree.  Right now I'm throwing away the tree after making the
changes and create the next tree (which is expected to be quite similar
in contents) from scratch, starting with an empty directory.  This is
quite slow.

Thanks,
Florian

```

## David Lloyd, 2017-08-30 14:15

Subject: Re: Produce contents of index with existing directory as cache
Message-ID: <CANghgrS9hZyA4vWU=4PZuYue3iLsLx7ObbT_VgRGSXpACwNkcg@mail.gmail.com>
URL: https://gitlist.dev/e/CANghgrS9hZyA4vWU%3D4PZuYue3iLsLx7ObbT_VgRGSXpACwNkcg%40mail.gmail.com
In-Reply-To: <5a9e4efd-8c48-487e-4a9f-9362a944c992@redhat.com>

```
git reset --hard ?

On Wed, Aug 30, 2017 at 9:11 AM, Florian Weimer <fweimer@redhat.com> wrote:
> Is there a variant of “git checkout-index” which will produce the
> existing index contents, like “git checkout-index” would do with an
> empty directory, but can reuse an existing directory tree, to avoid
> writing all files from scratch?
>
> I'm writing some analysis scripts which need to change a checked-out
> working tree.  Right now I'm throwing away the tree after making the
> changes and create the next tree (which is expected to be quite similar
> in contents) from scratch, starting with an empty directory.  This is
> quite slow.
>
> Thanks,
> Florian



-- 
- DML

```

## Florian Weimer, 2017-08-30 14:18

Subject: Re: Produce contents of index with existing directory as cache
Message-ID: <df9cb4e8-13f7-54b9-b737-be4e56977867@redhat.com>
URL: https://gitlist.dev/e/df9cb4e8-13f7-54b9-b737-be4e56977867%40redhat.com
In-Reply-To: <CANghgrS9hZyA4vWU=4PZuYue3iLsLx7ObbT_VgRGSXpACwNkcg@mail.gmail.com>

```
On 08/30/2017 04:15 PM, David Lloyd wrote:
> git reset --hard ?

That doesn't remove unstaged files.

Florian

```

## David Lloyd, 2017-08-30 14:55

Subject: Re: Produce contents of index with existing directory as cache
Message-ID: <CANghgrTFjybxfmn=DzKwvoqRP3GA3sWiGFtYdEfPZtWmyznq9g@mail.gmail.com>
URL: https://gitlist.dev/e/CANghgrTFjybxfmn%3DDzKwvoqRP3GA3sWiGFtYdEfPZtWmyznq9g%40mail.gmail.com
In-Reply-To: <df9cb4e8-13f7-54b9-b737-be4e56977867@redhat.com>

```
Ah, does it not?  Perhaps add a "git clean -d -f" as well.

On Wed, Aug 30, 2017 at 9:18 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 08/30/2017 04:15 PM, David Lloyd wrote:
>> git reset --hard ?
>
> That doesn't remove unstaged files.
>
> Florian



-- 
- DML

```

## Florian Weimer, 2017-08-31 09:58

Subject: Re: Produce contents of index with existing directory as cache
Message-ID: <8ca2e078-88d2-83db-bc28-5f8fbf3c0dd6@redhat.com>
URL: https://gitlist.dev/e/8ca2e078-88d2-83db-bc28-5f8fbf3c0dd6%40redhat.com
In-Reply-To: <CANghgrTFjybxfmn=DzKwvoqRP3GA3sWiGFtYdEfPZtWmyznq9g@mail.gmail.com>

```
On 08/30/2017 04:55 PM, David Lloyd wrote:
> On Wed, Aug 30, 2017 at 9:18 AM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 08/30/2017 04:15 PM, David Lloyd wrote:
>>> git reset --hard ?
>>
>> That doesn't remove unstaged files.

> Ah, does it not?  Perhaps add a "git clean -d -f" as well.

It would have to be “git clean -d -f -f -x” (not the two “-f”) to be on
the safe side.  I wonder what else I'm missing, though, and if this is
completely reliable and has the same effect as removing the tree before
“git checkout-index”.

Thanks,
Florian

```
