Interview Prep/Git & GitHub/Secrets, Signing and Security

A push is rejected: "GH013: Repository rule violations found ... Push cannot contain secrets". What do you do?

IntermediateScenarioSecrets, Signing and Security
Answer

Situation read → GitHub push protection detected a known secret pattern in your commits.

What I'd do →

  1. Read the message; it names the file and commit.
  2. Remove the secret from the commit, not just the latest file state: amend or interactive rebase, so no commit in the push contains it.
  3. Load the value from an environment variable or secret manager instead.
  4. If it is a verified false positive or test token, use the bypass link and choose a reason; that is logged.

Why → Blocking before the push means the secret never reaches the remote, which beats cleaning afterwards.

Interview tip → Treat a real hit as a leak anyway if the secret was ever valid: rotate it.

All Git & GitHub questions Roadmap: Git & GitHub

More on Secrets, Signing and Security