Problem with git reset on rolling back to the previous commit
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 t开发者_StackOverflowhe 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, 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...
Use http://git-scm.com/docs/git-filter-branch, but on your own risk!
精彩评论