Rotate the key first — treat it as leaked the moment it was pushed. Everything below is cleanup, not remediation.
For a shared branch, prefer a forward fix:
This adds a new commit undoing the change and breaks nobody's history. The secret is still in the old commit, which is why rotation is not optional.
If the history genuinely must be scrubbed (compliance, public repo), rewrite and coordinate:
Then every collaborator re-clones. Use --force-with-lease rather than --force so you don't clobber someone's push that landed while you were rewriting.