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, 01:06 UTC
Message-ID
<20071008010648.GB29433@potapov>
In-Reply-To
<51419b2c0710071722k576c06d9i2f4dce730eae2059@mail.gmail.com>
On Sun, Oct 07, 2007 at 06:22:28PM -0600, Elijah Newren wrote:
Show 10 quoted lines
> 
> git-filter-branch --tree-filter 'rm -f testme.txt' HEAD
> git reset --hard
> rm -rf .git/refs/original/
> vi .git/packed-refs
> # Use vi to remove the line referring to refs/original...
> git reflog expire --all --expire-unreachable=0
> git gc --prune
> 
> Seems like a wrapper is needed.  :-)

Actually, I would rather not, because you rarely need to remove anything immediately, and 30 days delay is reasonable time to give you a chance to recover that you removed accidentally. You can reduce it by setting appropriate value for gc.reflogExpireUnreachable in your configuration. The only thing you need to do is to remove .git/refs/original/heads/something after you are sure that git-filter-branch did exactly what you wanted.

> 
> > Warning: all unreachable references will be removed!
> 
> What other scenarios could lead to unreachable references?
Any re-writing of history leads to that.
> I don't
> know how to determine whether this is safe or not (except that these
> were test repositories anyway, so I don't care what happens to them).

Git logs all your action, so even re-writing history would not be so disastrous if you suddenly realized that you did something wrong. The history is stored for 30 days by default. Usually, you do not need to mess with Git internals like you did above. Your useless files still will disappear after being unreachable for 30 days.

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.

Dmitry
Previous: Elijah NewrenNext: Andreas Ericsson
Message 12 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.