Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I made a huge mistake.

I made a repo with some files. I made some commits, everything was working right. But then I realized, 2 files had a very very huge mistake, which made them about 200 Mb in size, when they should be about 2 Mb (no joking). They are on the root commit. I managed to ammend the root commit with the right files, but my repo is still about 500 Mb, which makes it very hard to manage. If I reset to root commit, those files are the right files.

I haven't pushed to a central repo yet because of this. It just takes forever to upload 500 MB.

So, I was wondering how could I delete those 200Mb files from repo, even if they are no more in any commit. Which commands should I use? Should I simply delete biggest blob files? Am I crazy? Did I make something really really wrong?

Thanks. I'm really in a hurry.


I had already ran git gc, but it only reduced it about 40 Mb. I think those nasty files are still there, so I´m not sure what to do.

share|improve this question

migrated from Mar 5 '13 at 9:32

This question came from our site for professional and enthusiast programmers.

Does git gc end up removing those files? – Anton I. Sipos Mar 5 '13 at 8:04
up vote 0 down vote accepted

The easiest way to shrink down your local repo (not needed for pushing, as Micheal Anderson stated correctly) is to go to a different dir and run git clone /path/to/your/repo. This new repo should be small now – continue your work there.

share|improve this answer
So darn easy... and elegant... Thank you very much. – Bul Ikana Mar 7 '13 at 15:58

To prune the files from the repo history you can use git filter-branch. However this just removes the files from all the trees, you may still have the file contents sitting about in blobs inside the git object cache. You can clean them out using git gc.

However you dont need to worry about those unattached blobs getting pushed up to the main repo, as only blobs attached the to commit tree you are pushing up get sent to the other server.

If you've already pushed up the big files then cleaning out the unatached blobs on the remote repo is trickier. See how to do `git gc' on git remote repository

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .