How can I permanently delete a commit from Git\'s history?
One of the developers on the team has accidentally committed a 200 MB file and pushed it to our Git server. It
As forvaidya suggested, git filter-branch
is the way to go. Specifically, in your case, you can execute the following command to remove that one file from the repo's history:
git filter-branch --tree-filter 'rm -f filename' HEAD
Substitute filename
with the actual file name. Again, as forvaidya said, this rewrites the entire history of the repo so anyone who pulls after you make this change will get an error.
Edit: for performance reasons, it's actually better to use Git's rm
command:
git filter-branch --index-filter 'git rm --cached --ignore-unmatch filename' HEAD