It's a fairly common problem when people realise they have inadvertently committed a secrets file.
You could say "well don't commit secrets files" but that doesn't immediately solve the problem.
In that case the secret is blown so you rotate it and leaving in the repo isn't an issue.
Unless you mean some intentionally weird scenario, where you want to just delete the file to prevent it from being accessible period. But that's (afaik) against the whole concept of git, and so verry much outside the intended use.
Do I understand your example?