threads / discuss / 28925

delete deprecated refs to release disk space

Subject: delete deprecated refs to release disk space

## tl;dr

4 messages between Nov 13, 2011 and Nov 16, 2011.

replies: 3people: 2as markdown or json

Peter Vereshagin· Nov 13, 2011, 15:10 UTC · lore
Hello.
I use git for sql database backups:
    http://gitweb.vereshagin.org/endvance/blob_plain/HEAD:/endvance/README

Am wondering if there is a way to remove the expired revisions? Following that scenario:

    https://gist.github.com/1362183

I think there should be the way to decrease the space that .git takes. Without compression, of course.

No problem if this involves the overwriting of the history like filter-branch does. But filter-branch doesn't seem to be able to remove the old info from repository based on expiration time, does it?

Thank you.

-- Peter Vereshagin <peter@vereshagin.org> (http://vereshagin.org) pgp: A0E26627

Ævar Arnfjörð Bjarmason· Nov 13, 2011, 17:01 UTC · re: Peter Vereshagin · lore

Re: delete deprecated refs to release disk space

2011/11/13 Peter Vereshagin <peter@vereshagin.org>:
Show 17 quoted lines
> Hello.
>
> I use git for sql database backups:
>
>    http://gitweb.vereshagin.org/endvance/blob_plain/HEAD:/endvance/README
>
> Am wondering if there is a way to remove the expired revisions? Following that
> scenario:
>
>    https://gist.github.com/1362183
>
> I think there should be the way to decrease the space that .git takes. Without
> compression, of course.
>
> No problem if this involves the overwriting of the history like  filter-branch
> does.  But filter-branch doesn't seem to be able to remove the old  info  from
> repository based on expiration time, does it?

What you're looking for is git-filter-branch + the graft facility. I can't remember the exact invocation, but you echo the sha1 of the commit you want to be the oldest commit to .git/info/grafts, then run git-filter-branch.

You can use whatever you like to discover that sha1, e.g. keep N revisions (which might be committed once per day) around, or have some custom time limit etc.

Peter Vereshagin· Nov 14, 2011, 14:25 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: delete deprecated refs to release disk space

Hello.

2011/11/13 18:01:18 +0100 ??var Arnfj??r?? Bjarmason <avarab@gmail.com> => To Peter Vereshagin : vArB> What you're looking for is git-filter-branch + the graft facility. I vArB> can't remember the exact invocation, but you echo the sha1 of the vArB> commit you want to be the oldest commit to .git/info/grafts, then run vArB> git-filter-branch.

Seem to work for me ( with 'gc' and 'prune' thereafter ) but with these quirks: *) the git-filter-branch(1) tells that there must be two ids:

    echo "$commit-id $graft-id" >> .git/info/grafts

This works for me if only one is put there. *) I'd like to have a command for this. Is this a '--parent-filter' to make the same thing?

N commits ago is a fine setting for me as it's a cron job backup. Thanks?

-- Peter Vereshagin <peter@vereshagin.org> (http://vereshagin.org) pgp: A0E26627

Peter Vereshagin· Nov 16, 2011, 23:44 UTC · re: Peter Vereshagin · lore

Re: delete deprecated refs to release disk space

Hello.

2011/11/14 18:25:25 +0400 Peter Vereshagin <peter@vereshagin.org> => To ??var Arnfj??r?? Bjarmason : PV> N commits ago is a fine setting for me as it's a cron job backup. Thanks?

* = Thanks!
Here is the PoC QnD code that releases disk space for me by far:
    git rev-list --all --timestamp |\
        perl -Mstrict -MTime::ParseDate -wE \
            'my $match = 0; my $expire = parsedate( "3 days ago" ); while (<>)
                { chomp; my ( $tstamp => $graft_id ) = split /\s+/;
                    if ( not( $match ) and $tstamp < $expire )
                        { say $graft_id; $match = 1; } }
            ' > .git/info/grafts && \
    git filter-branch -f
for case a one shall seek for it.

-- Peter Vereshagin <peter@vereshagin.org> (http://vereshagin.org) pgp: A0E26627

← back to recent threads