2

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.

[UPDATE]

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.

1
  • Does git gc end up removing those files? Mar 5, 2013 at 8:04

2 Answers 2

0

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.

1
  • So darn easy... and elegant... Thank you very much.
    – Hugo A
    Mar 7, 2013 at 15:58
2

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 https://stackoverflow.com/questions/3162786/how-to-do-git-gc-on-git-remote-repository

You must log in to answer this question.

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