GitHub Push Blocked: Repository Rule Violations (GH013 / Secret Detected)
Quick answer
GitHub push protection found something that looks like a secret in a commit you are pushing. Remove it from every commit being pushed (not just the latest file), revoke it if it was real, and push again.
Most likely fix: Read which commit and file contains the secret
How to fix it
Try these in order — the most common fix is first.
1. Read which commit and file contains the secret
- The error output lists the secret type, commit SHA and path
- If the secret was real, revoke or rotate it first
Did this fix it?2. Remove it from the latest commit
- Delete the secret from the file and move it to an environment variable
- git add the file and run git commit --amend
- git push
Did this fix it?3. Remove it from older unpushed commits
- Run git rebase -i origin/main~N or git reset --soft to the last clean commit
- Recommit without the secret and push
- For secrets deep in history use git filter-repo
Did this fix it?4. Bypass only for false positives or test values
- Open the URL printed in the push error
- Choose the reason (false positive, used in tests, will fix later) and push again
- Bypass requests can alert admins and may need approval on some organizations
Did this fix it?
Symptoms
git push fails with 'GH013: Repository rule violations found' and 'Push cannot contain secrets', listing the file, line and commit.
Why it happens
- A token, API key or credential is in one of the commits being pushed
- The secret was committed earlier, so deleting it in a new commit still leaves it in history
- A test value or false positive matches a secret pattern
- An organization ruleset blocks the push for other reasons (the message lists the rule)
This guide also covers
- gh013 repository rule violations found
- github push protection blocked push secret
- push cannot contain secrets github
- github remove secret from commit history
Still not working?
If GitHub keeps failing, you're not alone. See every GitHub problem users report or the alternatives people switch to.
Need a custom web app or internal tool? Our small team builds it, on your domain or hosted by us. Price agreed together.
Get a quoteOther GitHub errors
- GitHub Permission Denied (publickey) Error
- GitHub 'Password Authentication Was Removed' Error
- GitHub Push Rejected: Updates Were Rejected (Non-Fast-Forward)
- GitHub Push Rejected: File Exceeds 100 MB Limit
- GitHub 'Permission Denied' or 403 When Pushing Over HTTPS
- GitHub Locked Out: Lost 2FA Device or Recovery Codes
- GitHub Actions Workflow Stuck in Queued / Waiting for a Runner
- GitHub Actions: 'Recent Account Payments Have Failed or Spending Limit Needs to Be Increased'