git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Dmitry Potapov <dpotapov@gmail.com>
Date
Oct 8, 2007, 12:40 UTC
Message-ID
<20071008124017.GA22129@potapov>
In-Reply-To
<4709F805.8050704@op5.se>
On Mon, Oct 08, 2007 at 11:27:33AM +0200, Andreas Ericsson wrote:
Show 8 quoted lines
> Dmitry Potapov wrote:
> >OTOH, if you want to have a clean repository immediately, I believe
> >'git clone' is a better option. After you made a local clone using
> >it, 'git gc' should remove old garbage.
> >
> 
> A clone only fetches revs reachable from a ref, so pruning immediately
> after a clone is completely pointless.

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
Previous: Karl HasselströmNext: Karl Hasselström
Message 15 of 31 in “Trying to use git-filter-branch to compress history by removing large, obsolete binary files”
  1. Elijah NewrenOct 7, 2007
  2. Frank LichtenheldOct 7, 2007
  3. Elijah NewrenOct 7, 2007
  4. Alex RiesenOct 7, 2007
  5. Elijah NewrenOct 7, 2007
  6. Alex RiesenOct 7, 2007
  7. Elijah NewrenOct 8, 2007
  8. Alex RiesenOct 8, 2007
  9. Andreas EricssonOct 8, 2007
  10. Dmitry PotapovOct 7, 2007
  11. Elijah NewrenOct 8, 2007
  12. Dmitry PotapovOct 8, 2007
  13. Andreas EricssonOct 8, 2007
  14. Karl HasselströmOct 8, 2007
  15. Dmitry PotapovOct 8, 2007
  16. Karl HasselströmOct 8, 2007
  17. Johannes SchindelinOct 7, 2007
  18. Elijah NewrenOct 7, 2007
  19. Johannes SchindelinOct 7, 2007
  20. Elijah NewrenOct 7, 2007
  21. Johannes SchindelinOct 8, 2007
  22. Elijah NewrenOct 8, 2007
  23. Sam VilainOct 8, 2007
  24. J. Bruce FieldsOct 8, 2007
  25. Johannes SchindelinOct 8, 2007
  26. Johannes SixtOct 8, 2007
  27. J. Bruce FieldsOct 8, 2007
  28. Theodore TsoOct 8, 2007
  29. J. Bruce FieldsOct 8, 2007
  30. Johannes SchindelinOct 9, 2007
  31. Alex RiesenOct 7, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.