Source: https://stackoverflow.com/questions/2164581/remove-file-from-git-repository-history
This is the shortest way to get rid of the files:
- (Optional) Check for the largest files
git verify-pack -v .git/objects/pack/#{pack-name}.idx | sort -k 3 -n | tail -5
- (Optional) Check what are those files
git rev-list --objects --all | grep <id>
- remove a file from all revisions
git filter-branch --index-filter 'git rm --cached --ignore-unmatch <files>'
- Remove git backup
rm -rf .git/refs/original/ # to remove git's backup
- Expire loose objects
git reflog expire --all --expire='0 days' # to expire all the loose objects
- Check for loose objects
git fsck --full --unreachable # to check if there are any loose objects
- Repack
git repack -A -d # repacking
- Remove and prune
git prune