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?
Even if you move the branch pointer back in this way,
gitdoesn’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 agit reset --hard, then you can recover the old commits easily, typically by using thereflogto 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:However, one almost never needs to do this…