This is a way how to remove a file from the history
How Remove Files completely from git repository history
#first find the commits, e.g. to lookup the exact path
git log --all --full-history -- **/terraform-provider-azurerm*
#get the details of a commit. This gives the exact filenames
git show --pretty="" --name-only c7393543cf5427c037ed3e0f285ed286f3a8e73b
#Clone the repo in a new folder
git clone https://someaccount@dev.azure.com/someaccount/project/_git/reponame repair
cd repair/
#Fix the given file with full path
# https://myopswork.com/how-remove-files-completely-from-git-repository-history-47ed3e0c4c35
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch terraform/.terraform/terraform-provider-random_v3.1.0_x5" HEAD
#push it back to the repository
git push origin main --all # (or --force if not working)
The full problem is more complicated. See e.g.