removing large files in git

If you add a large file in git -- say, a video -- and delete it, it will still be present in the repo. That's because git stores history, and so it will be present in previous git commits, the git reflog, etc.

To fix:

# if the files were added in one or more commit on their own
git rebase -i <commit>~1

# otherwise
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch UNWANTED_FOLDER_OR_FILE' --prune-empty

# Next step, to perform a GC cycle to force all references to the file to be expired and purged from the packfile. 

git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin
# or, for older git versions (e.g. 1.8.3.1) which don't support --stdin
# git update-ref $(git for-each-ref --format='delete %(refname)' refs/original)
git reflog expire --expire=now --all
git gc --aggressive --prune=now