Skip to contentSkip to conversation

delete deprecated refs to release disk space

DISCUSSION Peter Vereshagin 2 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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 <[email protected]> (http://vereshagin.org) pgp: A0E26627

#1 lore raw

2011/11/13 Peter Vereshagin <[email protected]>:

Quoted 9 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:

Quoted 8 lines

   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.

#2 lore raw

Hello.

2011/11/13 18:01:18 +0100 ??var Arnfj??r?? Bjarmason <[email protected]> => 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 <[email protected]> (http://vereshagin.org) pgp: A0E26627

#3 lore raw

Hello.

2011/11/14 18:25:25 +0400 Peter Vereshagin <[email protected]> => 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 <[email protected]> (http://vereshagin.org) pgp: A0E26627