- Add or update a
.gitignore
file - Rebase your repo such that the
.gitignore
from step one is positioned in history prior to the naughty file(s) being commited. - Run this command, where
<commit>
is the hash for the commit respresented by step 1:git rebase -ix 'git rm -r --cache . && git add . && git commit --amend --no-edit' <commit>
- Resolve conflicts as necessary.
Note that if there are only a few file types or directories or individual files, filter-branch
is a simpler route to take. These steps are only necessary for large numbers of files / file types. Also note that there may be better ways still of doing this. :-)
This is great, thanks!