Following situation: I have a git repo with a lot of commits, and I want to remove a file that was introduced in a commit changed in a few and finally deleted in a commit. S
The canonical guide to removing the commit is here. It in essence gives two routes, git-filter-branch
, and bfg
.
However, if you really mean completely remove, you are missing step 9 in that process, i.e. :
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin
git reflog expire --expire=now --all
git gc --prune=now
which will actually delete the unused references.
Note also that if these are either sensitive data that should never have been committed, or they are just huge (so you don't want a git pull
to pull them down again), you need to ensure they are removed from:
Note also the comment in there about getting collaborators to rebase rather than merge.