xxxxxxxxxx
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch path_to_file" HEAD
xxxxxxxxxx
git filter-repo --invert-paths --path <path to file>
git push --force origin main
xxxxxxxxxx
// If you want to remove the file from the Git repository and the filesystem, use:
git rm file1.txt
git commit -m "remove file1.txt"
// But if you want to remove the file only from the Git repository and not remove it from the filesystem, use:
git rm --cached file1.txt
git commit -m "remove file1.txt"