Reduce git repository size

I tried looking for a good tutorial on reducing repo size, but found none. How do I reduce my repo size…it’s about 10 MB, but the thing is Heroku only allows 50 MB and I’m no where near finished developing my app.

I added the usual suspects (log, vendor, doc etc) to .gitignore already. Although I only added .gitignore recently.

  • Is there a way to backup a branch in git and be able to “reimport” it?
  • Jenkins not playing nice with a private GitHub repository (Windows)
  • What's the fastest way to get all build errors in a Java project?
  • Create Git commits and push to GitHub with Ruby
  • Corrupted Git Repository (data stream error)
  • How to reduce the size of a repo on Github
  • Any suggestions?

  • How to solve git conflicts by having only the conflict files?
  • git clone of git itself creates Git dir which is hardlinked to git
  • Revert all commits by a specific author since specific time
  • Can I edit two files then make one commit using GitHub Web-based editor?
  • gitpython error when checking if repo is dirty
  • How work git ls-files script
  • 2 Solutions collect form web for “Reduce git repository size”

    git gc --aggressive is one way to force the prune process to take place (to be sure: git gc --aggressive --prune=now). You have other commands to clean the repo too. Don’t forget though, sometimes git gc alone can increase the size of the repo!

    It can be also used after a filter-branch, to mark some directories to be removed from the history (with a further gain of space); see here. But that means nobody is pulling from your public repo. filter-branch can keep backup refs in .git/refs/original, so that directory can be cleaned too.

    Finally, as mentioned in this comment and this question; cleaning the reflog can help:

    git reflog expire --all --expire=now
    git gc --prune=now --aggressive
    

    An even more complete, and possibly dangerous, solution is to remove unused objects from a git repository

    Thanks for your replies. Here’s what I did:

    git gc
    git gc --aggressive
    git prune
    

    That seemed to have did the trick. I started with around 10.5MB and now its little more than 980KBs.

    Git Baby is a git and github fan, let's start git clone.