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 repository install remote fatal remotely locally delete branch repository remote svn get repositories文件remote maven repository specified代码remote repository错误remote clone permanent permanently sample-based permanent and transient