Above answers didn't work for me. I used filter-branch
to remove all committed files.
Remove a file from a git repository with:
git filter-branch --tree-filter 'rm file'
Remove a folder from a git repository with:
git filter-branch --tree-filter 'rm -rf directory'
This removes the directory or file from all the commits.
You can specify a commit by using:
git filter-branch --tree-filter 'rm -rf directory' HEAD
Or an range:
git filter-branch --tree-filter 'rm -rf vendor/gems' t49dse..HEAD
To push everything to remote, you can do:
git push origin master --force