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

Re: Problems getting rid of large files using git-filter-branch

From
Nicolas Pitre <nico@cam.org>
Date
Jan 7, 2009, 15:02 UTC
Message-ID
<alpine.LFD.2.00.0901070955500.26118@xanadu.home>
In-Reply-To
<c09652430901070026m6ca0ec98ndc7483aac8dfde89@mail.gmail.com>
On Wed, 7 Jan 2009, Øyvind Harboe wrote:
Show 31 quoted lines
> Here is a summary of the solution I used. I'm a beginner in git
> and just summarizing what others told me and what I did. Use at
> your own risk!
> 
> 1. Remove anything you know should be removed, e.g.:
> 
> git filter-branch --tree-filter 'find . -regex ".*toolchain\..*" -exec
> rm -f {} \;' HEAD
> 
> 2. Expire the log:
> 
> git reflog expire --all
> 
> 3. Delete stuff from .git that should be manually "verified" to be
> correct. I don't actually
> know how to "verify" that at this point... Use backups Luke!
> 
> rm -rf .git/refs/original
> # delete lines w/"refs/original" from .git/packed-refs
> vi .git/packed-refs
> # for good measure...
> git reflog expire --all
> git gc
> 
> 4. Your repository is still huge. By creating a new repository and pulling from
> this one, the garbage will stay in the old one...
> 
> mkdir newrep
> cd newrep
> git init
> git pull file:///oldrep

I'd suggest you skip 2 and 3, and do 4 only. Using 4 makes 2 unnecessary, and is far safer than 3. Manually deleting stuff in .git is fine only if you really know what you're doing and have some acquaintance with the git internals.

Show 27 quoted lines
> 5. Check size of .git. If it is still too big, try figuring out which
> files that are big by looking at the packs(.git/objects/pack/xxx):
> 
> $ git verify-pack -v $PACK | grep -v "^chain " | sort -n -k 4
> 
> and then for the last few lines do a
> 
> $ git rev-list --all --objects | grep $SHA1
> 
> 6. Go back to #1 until done.
> 
> Your repository should now be of reasonable size...
> 
> I've found some great scripts for converting from svn/cvs, but really
> the above procedure
> is necessary to run when converting nasty old repositories...
> 
> -- 
> Øyvind Harboe
> http://www.zylin.com/zy1000.html
> ARM7 ARM9 XScale Cortex
> JTAG debugger and flash programmer
> --
> 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: Øyvind Harboe
Message 13 of 13 in “Problems getting rid of large files using git-filter-branch”
  1. Øyvind HarboeJan 6, 2009
  2. Johannes SchindelinJan 6, 2009
  3. Øyvind HarboeJan 6, 2009
  4. Johannes SchindelinJan 7, 2009
  5. Øyvind HarboeJan 7, 2009
  6. Johannes SchindelinJan 7, 2009
  7. Sitaram ChamartyJan 7, 2009
  8. Nicolas PitreJan 6, 2009
  9. Øyvind HarboeJan 6, 2009
  10. Stephen R. van den BergJan 6, 2009
  11. Nicolas PitreJan 7, 2009
  12. Øyvind HarboeJan 7, 2009
  13. Nicolas PitreJan 7, 2009

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.