First run
git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch FOLDERNAME" -- --all
Then shrink the .git folder
rm -rf .git/refs/original/ git reflog expire --expire=now --all git gc --prune=now git gc --aggressive --prune=now
Now push all the changes to the remote repository
git push --all --force
**Acknowledgement to https://stackoverflow.com/a/24526351
- repositories permanently delete stored remoterepositories permanently delete stored remotely locally delete branch repositories文件remote maven repository错误remote clone repository specified代码remote repository install remote fatal repository remote svn get permanent sample-based permanent and transient 指令permanent redirect rewrite