1

I accidentally committed the huge unwanted folder and pushed it to master in git. And i had one more commit after that. so its like this

A - B - C - D

C - is the problematic commit

After realizing the mistake i used the command

git reset --hard <sha1-commit-id-of-B>

and

git push origin HEAD --force

to rollback to the B. It was fine, but the size of the repo is still same. i was confused. how can i get rid of the unwanted files(permanently), so it wont appear on the git?

RameshVel
  • 64,778
  • 30
  • 169
  • 213

2 Answers2

3

Even if you move the branch pointer back in this way, git doesn't immediately garbage-collect the objects that are now no longer referenced. This is a good thing - it means, for example, that if you mistakenly do a git reset --hard, then you can recover the old commits easily, typically by using the reflog to find the object names of those commits, and creating a branch from one of them. If you really want to garbage collect immediately to reclaim the space, you can do:

git gc --prune=now

However, one almost never needs to do this...

Mark Longair
  • 446,582
  • 72
  • 411
  • 327
  • thanks mark, that's all i needed. Its a relief that i dont need to garbage collect it manually, i ll let git do it the gc.. :) – RameshVel Aug 25 '11 at 08:41
0

Use http://git-scm.com/docs/git-filter-branch, but on your own risk!

Sergey Miryanov
  • 1,820
  • 16
  • 29