# git gc and git repack

2 messages from 2007-03-06 to 2007-03-06. Participants: Sergio Callegari, Johannes Schindelin.
Thread: https://gitlist.dev/t/7112

## Sergio Callegari, 2007-03-06 16:13

Subject: git gc and git repack
Message-ID: <loom.20070306T165455-693@post.gmane.org>
URL: https://gitlist.dev/e/loom.20070306T165455-693%40post.gmane.org

```
Hi,

I am puzzled by a different behavior when doing housekeeping with git-gc and
git-repack:

On a repository I have, git gc gives:

Generating pack...
Done counting 75 objects.
Deltifying 75 objects.
 100% (75/75) done
Writing 75 objects.
 100% (75/75) done
Total 75 (delta 26), reused 68 (delta 26)
Pack pack-a989a4c4c7454874220cf502865ab9a28952499f created.
Removing unused objects 100%...
Done.

while git repack -a -d gives

Generating pack...
Done counting 143 objects.
Deltifying 143 objects.
 100% (143/143) done
Writing 143 objects.
 100% (143/143) done
Total 143 (delta 49), reused 120 (delta 31)
Pack pack-d17fd54437f04fbde34088909e31e95718e7b8c5 created.
Removing unused objects 100%...
Done.

Why is a different number of objects being considered in the two case, with git
repack considering more objects and producing a different pack? Also, the
package produced by repack turns out to be much larger than the one by git gc...
In any case, both packages turn out to be git-fsck clean...

I suspect, this has to to with my repository using alternates... (in fact git-gc
and git-repack start behaving identically if I pass the -l (local) option to
repack...  can anyone confirm that this is the only difference?

Also can anybody confirm whether git repack -a -d actually includes in the pack
also _all_ the "borrowed" objects? I.e. if it is in fact a way to convert a
repository that borrows objects into one that is self-standing?

```

## Johannes Schindelin, 2007-03-06 21:13

Subject: Re: git gc and git repack
Message-ID: <Pine.LNX.4.63.0703062211450.22628@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0703062211450.22628%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <loom.20070306T165455-693@post.gmane.org>

```
Hi,

On Tue, 6 Mar 2007, Sergio Callegari wrote:

> I am puzzled by a different behavior when doing housekeeping with git-gc and
> git-repack:
>
> [...] 
> Done counting 75 objects.
> [...]
>
> while git repack -a -d gives
> 
> Done counting 143 objects.
> 
> I suspect, this has to to with my repository using alternates... (in 
> fact git-gc and git-repack start behaving identically if I pass the -l 
> (local) option to repack...  can anyone confirm that this is the only 
> difference?

Yes. And if you look in git-gc, you'll see as to why: it uses the -l flag.

> Also can anybody confirm whether git repack -a -d actually includes in 
> the pack also _all_ the "borrowed" objects? I.e. if it is in fact a way 
> to convert a repository that borrows objects into one that is 
> self-standing?

Yes exactly.

Ciao,
Dscho

```
