Now the ways back, from the safest to the most dangerous.
Revert
Undoing a commit by adding a new commit that does the opposite. The mistake stays in the history along with its undoing, and nobody else's copy is disturbed.
This is the undo for anything already pushed. It needs no force, it can't lose anyone's work, and it leaves a record of what went wrong and that someone dealt with it. Make it your agent's default, because left to itself it may reach for something worse.
Say it to your agent
“Commit a1b2c3d broke checkout and it is on main. Undo it with git revert a1b2c3d, on a new branch, through a pull request. Don't use reset or force push. Say in the message what broke and how we know.”