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.

  • Git shows status clean, but checkout complains about overwriting untracked files
  • How do you remove a file from the global .gitignore list in Sourcetree?
  • Rename branch 'a' to master
  • how to fetch only commits history, not files using git
  • How do I move recent (but not latest) commits to a new branch
  • Git asks for password for each commit and pull
  • This is a serious problem, I keep screwing up with Git! Would like some good starting guide to Git.

  • Git submodule track commit but know branch?
  • Which Git merge strategy is better?
  • Easiest way to do “git grep” for multiple strings?
  • Git in a decentralised mode: do we have to add all remotes ? And how do I know which remote to pull from?
  • Building/Waiting for parent job Latest version
  • write puppet config to clone github repo
  • 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
    Git Baby is a git and github fan, let's start git clone.