Re: Trying to use git-filter-branch to compress history by removing large, obsolete binary files

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Dmitry Potapov
Date: Monday, October 8, 2007 - 5:40 am

On Mon, Oct 08, 2007 at 11:27:33AM +0200, Andreas Ericsson wrote:

Not true. git-clone copies the whole pack, so it can contain unreachable
objects. Here is a simple script that demonstrates that without garbage
collection the size of the cloned repository will be the same as the
original one.

===========================================
# Make a small repo
mkdir test
cd test
git init
echo hi > there
git add there
git commit -m 'Small repo'

# Add a random 10M binary file
dd if=/dev/urandom of=testme.txt count=10 bs=1M
git add testme.txt
git commit -m 'Add big binary file'

# Remove the 10M binary file
git rm testme.txt
git commit -m 'Remove big binary file'

# Compress the repo, see how big the repo is
git gc --aggressive --prune
du -ks .                       # 10348
du -ks .git                    # 10344

git-whatchanged

# Try to rewrite history to remove the binary file
git-filter-branch --tree-filter 'rm -f testme.txt' HEAD
git reset --hard

# Remove original refs
rm .git/refs/original/refs/heads/master

# Remove back
cd ..

# Clone repository
git-clone -l test/.git test2

cd test2
du -ks .git # 10360

# Now run garbage collection
git gc
du -ks .git # 96

===========================================

Dmitry
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: Trying to use git-filter-branch to compress history by ..., Johannes Schindelin, (Sun Oct 7, 4:19 pm)
Re: Trying to use git-filter-branch to compress history by ..., Johannes Schindelin, (Sun Oct 7, 4:28 pm)
Re: Trying to use git-filter-branch to compress history by ..., Johannes Schindelin, (Sun Oct 7, 5:34 pm)
Re: Trying to use git-filter-branch to compress history by ..., Johannes Schindelin, (Sun Oct 7, 6:06 pm)
Re: Trying to use git-filter-branch to compress history by ..., Dmitry Potapov, (Mon Oct 8, 5:40 am)
Re: Trying to use git-filter-branch to compress history by ..., Johannes Schindelin, (Tue Oct 9, 3:37 am)