git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch <path to the file or directory>' --prune-empty --tag-name-filter cat -- --all
pip3 install git-filter-repo
git filter-repo --path <path to the file or directory> --invert-paths