# Re: git prune pig slow

2 messages from 2006-07-29 to 2006-07-29. Participants: linux@horizon.com, Linus Torvalds.
Thread: https://gitlist.dev/t/5041

## linux@horizon.com, 2006-07-29 22:41

Subject: Re: git prune pig slow
Message-ID: <20060729224106.12312.qmail@science.horizon.com>
URL: https://gitlist.dev/e/20060729224106.12312.qmail%40science.horizon.com

```
> Btw, another alternative to "git prune" is actually to do
>
>	git repack -a -d
>
> and then just delete all unpacked objects.

No, that's dangerous too.  The index file is considered part of the root
set for git-fsck-objects, but not for git-repack.

Example script:

$ git-init-db
$ cat > hello.c
#include <stdio.h>

int
main(void)
{
        puts("Hello, world!");
        return 0;
}
$ git-update-index --add hello.c
$ git-repack -a -d
Generating pack...
Done counting 0 objects.
Nothing new to pack.
$ rm .git/objects/67/159ba959e0a0cd6157bf04d5dad66af59383c2
rm: remove write-protected regular file `.git/objects/67/159ba959e0a0cd6157bf04d5dad66af59383c2'? y
$ git commit
error: invalid object 67159ba959e0a0cd6157bf04d5dad66af59383c2
fatal: git-write-tree: error building trees

```

## Linus Torvalds, 2006-07-29 23:48

Subject: Re: git prune pig slow
Message-ID: <Pine.LNX.4.64.0607291647030.4168@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0607291647030.4168%40g5.osdl.org
In-Reply-To: <20060729224106.12312.qmail@science.horizon.com>

```


On Sat, 29 Jul 2006, linux@horizon.com wrote:
> 
> No, that's dangerous too.  The index file is considered part of the root
> set for git-fsck-objects, but not for git-repack.

Indeed.

Although at least you won't lose any history - at worst you'll have to 
basically do a "git reset HEAD" to make things right again.

I was careful when I wrote the new git-prune to take the index into 
account, but I'd forgotten about it wrt the "git repack -a -d" suggestion.

		Linus

```
