How to go back in history and remove a large binary file committed and pushed by accident in Git?
I did a
git pull --rebase without realizing it ended up downloading a huge binary file which was not supposed to be pulled. I did a commit and pushed my work along with this huge binary file.
I need to go back in time, remove it, and replay all of my work on top of all the pushes from other developers, there are other pushes to the repo. I was working on a separate branch.
This is a serious problem, I keep screwing up with Git! Would like some good starting guide to Git.
2 Solutions collect form web for “How to go back in history and remove a large binary file committed and pushed by accident in Git?”
take a look at
git filter-branch. This will get rid of the giant object from your local repo.
The other way to do it is to remove the addition of the giant file by using
git rebase -i HEAD~5 if your offending commit is 5 commits ago. Mark that commit with e for “edit”. When you get there, unstage and delete the giant file, commit and
git rebase --continue. Then do a force push
git push -f origin yourbranch or simply
git push -f if you have your branch tracked properly.
did you try to revert your last commit and push it again
git revert HEAD