# git repack -A -d doesn't remove objects found in alternates?

3 messages from 2021-09-17 to 2021-09-17. Participants: Uwe Kleine-König, Bryan Turner.
Thread: https://gitlist.dev/t/56520

## Uwe Kleine-König, 2021-09-17 08:56

Subject: git repack -A -d doesn't remove objects found in alternates?
Message-ID: <20210917085623.rjpmqqhb5xap26jd@pengutronix.de>
URL: https://gitlist.dev/e/20210917085623.rjpmqqhb5xap26jd%40pengutronix.de

```
Hello,

I wonder if I do something wrong, or if I just don't understand
something:

	ukl@dude04:~/work$ git version
	git version 2.30.2

	ukl@dude04:~/work$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
	...
	ukl@dude04:~/work$ cd linux/
	ukl@dude04:~/work/linux$ du -sh .git/objects
	2.6G    .git/objects
	ukl@dude04:~/work/linux$ echo "/ptx/work/user/git/linux.git/objects" > .git/objects/info/alternates

	ukl@dude04:~/work/linux$ git repack -A -d
	...
	ukl@dude04:~/work/linux$ du -sh .git/objects/
	2.6G	.git/objects/

I would have expected a drastic size decrease from git repack after the
alternate is added. Compare with:

	ukl@dude04:~/work$ time git clone --reference /ptx/work/user/git/linux.git https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-with-reference
	Cloning into 'linux-with-reference'...
	Updating files: 100% (73605/73605), done.

	ukl@dude04:~/work$ du -sh linux-with-reference/.git/objects/
	4.0K	linux-with-reference/.git/objects/

Can you spot the bug (or the wrong expectation)?

Thanks
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

```

## Bryan Turner, 2021-09-17 09:08

Subject: Re: git repack -A -d doesn't remove objects found in alternates?
Message-ID: <CAGyf7-E7PcRGiEd_U5bcw1na7H0LGDMw81s4SUDE=DH+4G3QYA@mail.gmail.com>
URL: https://gitlist.dev/e/CAGyf7-E7PcRGiEd_U5bcw1na7H0LGDMw81s4SUDE%3DDH%2B4G3QYA%40mail.gmail.com
In-Reply-To: <20210917085623.rjpmqqhb5xap26jd@pengutronix.de>

```
On Fri, Sep 17, 2021 at 1:56 AM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> Hello,
>
> I wonder if I do something wrong, or if I just don't understand
> something:
>
>         ukl@dude04:~/work$ git version
>         git version 2.30.2
>
>         ukl@dude04:~/work$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>         ...
>         ukl@dude04:~/work$ cd linux/
>         ukl@dude04:~/work/linux$ du -sh .git/objects
>         2.6G    .git/objects
>         ukl@dude04:~/work/linux$ echo "/ptx/work/user/git/linux.git/objects" > .git/objects/info/alternates
>
>         ukl@dude04:~/work/linux$ git repack -A -d
>         ...
>         ukl@dude04:~/work/linux$ du -sh .git/objects/
>         2.6G    .git/objects/
>
> I would have expected a drastic size decrease from git repack after the
> alternate is added.

You're missing -l on your repack command. See git help pack-objects
and look for --local. Without -l, repack includes copies of the
objects you're borrowing, so your pack size doesn't change.

Hope this helps!
Bryan

```

## Uwe Kleine-König, 2021-09-17 10:28

Subject: Re: git repack -A -d doesn't remove objects found in alternates?
Message-ID: <20210917102849.h7vru7j7dseoilps@pengutronix.de>
URL: https://gitlist.dev/e/20210917102849.h7vru7j7dseoilps%40pengutronix.de
In-Reply-To: <CAGyf7-E7PcRGiEd_U5bcw1na7H0LGDMw81s4SUDE=DH+4G3QYA@mail.gmail.com>

```
On Fri, Sep 17, 2021 at 02:08:58AM -0700, Bryan Turner wrote:
> On Fri, Sep 17, 2021 at 1:56 AM Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
> >
> > Hello,
> >
> > I wonder if I do something wrong, or if I just don't understand
> > something:
> >
> >         ukl@dude04:~/work$ git version
> >         git version 2.30.2
> >
> >         ukl@dude04:~/work$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> >         ...
> >         ukl@dude04:~/work$ cd linux/
> >         ukl@dude04:~/work/linux$ du -sh .git/objects
> >         2.6G    .git/objects
> >         ukl@dude04:~/work/linux$ echo "/ptx/work/user/git/linux.git/objects" > .git/objects/info/alternates
> >
> >         ukl@dude04:~/work/linux$ git repack -A -d
> >         ...
> >         ukl@dude04:~/work/linux$ du -sh .git/objects/
> >         2.6G    .git/objects/
> >
> > I would have expected a drastic size decrease from git repack after the
> > alternate is added.
> 
> You're missing -l on your repack command. See git help pack-objects
> and look for --local. Without -l, repack includes copies of the
> objects you're borrowing, so your pack size doesn't change.
> 
> Hope this helps!

It does. When adding -l the size reported by du goes down to 8K. Thanks
a lot.

While refering to other manpages is easy to maintain, it's hard to read
for a user.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

```
