Remove Local Commits

I lot of times I make this mistake to try to commit to Github some file which is 2 GB and it fails on the push

And the problem comes when trying to remove this file it’s still committed

So you need to delete your last commits but this will also delete all other changes

What I do is to copy the entire repository to new folder and delete the file

Then write this

git reset --hard HEAD~1

This removes the last commit. And do this until your branch is sync with the master remote branch

Then replace all files with the latest files but without the large file and the commit and push should work 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *