Skip to content

What does 'GH013: Repository rule violations found… Push cannot contain secrets' mean?

Short answer

GitHub push protection found a supported secret (an API key or token) in the commits you're pushing and blocked the push. Remove the secret from every commit being pushed: amend if it's in the latest commit, interactive-rebase if it's earlier. Move the value into an env var. Rotate it if it was ever pushed or shared elsewhere.

Last updated 2026-11-25 · Reviewed by ProofForge

The exact error

text
remote: error: GH013: Repository rule violations found for refs/heads/main.
remote: - GITHUB PUSH PROTECTION
remote:   —————————————————————————————————————————
remote:     Resolve the following violations before pushing again
remote:
remote:     - Push cannot contain secrets

Why it happens

  • A key was hard-coded in source or a committed .env file.
  • An earlier commit in the branch still contains it, even if a later commit deleted it.

How to fix it

  1. Latest commit only: delete the secret, then amend and push.
  2. Earlier commit: rebase back to it, edit, and continue.
  3. Add .env* to .gitignore and load the value from environment variables.
  4. If the secret has been pushed or shared anywhere before, rotate it with the provider. Removing it from git doesn't un-leak it.
bash
# secret is in the latest commit
git rm --cached .env   # or edit the file to remove the key
echo ".env*" >> .gitignore
git commit --amend --all
git push

# secret is in an earlier commit
git log                       # find the earliest commit with the secret
git rebase -i <COMMIT-ID>~1   # mark that commit as 'edit'
# remove the secret, then:
git add . && git commit --amend && git rebase --continue
git push

Check it's fixed

The push succeeds without a bypass, and a ProofForge scan of the live site finds no exposed .env or keys.

Check your live app

A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.

Read-only. No writes or row contents.

FAQ

Should I use the bypass link?

Only for false positives or test credentials. Bypassing pushes a real secret to GitHub.

Is deleting the file in a new commit enough?

No. The earlier commit still contains it, and push protection checks every commit you push.

Is my key safe now that the push was blocked?

If this was the first time it left your machine, yes. If it was pushed elsewhere, logged or shared, rotate it.

Sources

Related

Read as Markdown · Scan methodology