If you’ve ever created a project and you need to reomve a file (or folder) from a repository including from all past commits, the following will help you out. Make sure you backup the file’s you’re removing because you won’t be able to retrieve once it has gone.
git filter-branch --index-filter \
'git rm --cached --ignore-unmatch my_file_or_folder_name' \
--tag-name-filter cat -- --all
git push origin main --force
The above assumes the branch is ‘main’.