# 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.

> **Scan box (use the site's ScanBox component):** Check whether your live app has this problem. Paste your URL for a free outside-in scan covering exposed keys, open database rules, CORS and security headers. [Scan my app free →](https://proofforge.live/#scan)

## 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

- [GitHub: Working with push protection from the command line](https://docs.github.com/en/code-security/how-tos/secure-your-secrets/work-with-leak-prevention/push-protection-on-the-command-line)
- [GitHub: Remediating a leaked secret](https://docs.github.com/en/code-security/tutorials/remediate-leaked-secrets/remediating-a-leaked-secret)

## Related

- [Fix: .env file exposed](/fix/env-file-exposed)
- [Fix: .git folder exposed](/fix/git-folder-exposed)
- [GitHub key leaked: first 10 minutes](/leaked-keys/github)
- [.env file checker](/tools/env-file-checker)
- [All errors](/errors)
