GH013: Repository rule violations found
Last verified:
The fix
GitHub blocked the push because a commit still contains a secret. Push protection says Push cannot contain secrets. Rotate the key, then remove it from those commits.
- 1
Rotate the key first
Create a new key at the provider, put that value in the host's environment variables, redeploy, and confirm a real request works. Then revoke the key GitHub flagged. Deleting the line from the file does not invalidate a key that was already copied. Do this before you spend time rewriting history. If the key was in client code or a
NEXT_PUBLIC_/VITE_variable, move the call to the server or the new key leaks the same way. - 2
Take it out of the file
Remove the secret from the path named in the error. Read it from an environment variable that is not committed. If the value lived in
.env,.env.local, or a similar file, add that filename to.gitignoreand commit the ignore rule. Do not commit a.env.examplethat still contains the real value. - 3
Rewrite the latest commit, if that is the only one
If the error lists only your latest commit, GitHub's fix is to amend that commit and push again.
git commit --amend --allfolds every change in the working tree into that commit, so the secret has to already be gone, and you should not have unrelated edits you did not mean to include. If other edits are dirty, stage only the file you fixed and rungit commit --amendwithout--all. Thengit push. The rejected commits never landed, so this push does not need--force.git commit --amend --all git push - 4
Rewrite an earlier commit the same way
If the error lists an older commit, start at the earliest one it names:
git rebase -i <that-commit>~1. In the editor, changepicktoediton that commit. When the rebase stops, delete the secret, stage that file, amend, and continue. Then push. Do not open the unblock URL for a real key. If those commits are already on GitHub because you bypassed the block earlier, a normal push will not erase them. Rotating the key is what stops it working. Rewriting published history is a separate, disruptive step: GitHub's guide usesgit-filter-repoand a force push, and a teammate's old clone can push the secret back.git add path/to/file git commit --amend git rebase --continue git push
Why it happens
Push protection scans the commits in the push, not only the files you have open. The remote reports error: GH013: Repository rule violations found for the branch, and the violation is Push cannot contain secrets, with the commit and the file path. A newer commit that deletes the key does not clear an older commit that still has it. Force-pushing the same commits fails the same way.
The block means this push did not update the branch. Treat the key as exposed anyway. It is in your local history, and it may already be in an AI chat, a host log, or an earlier push. GitHub's guidance on a real secret is to rotate it and then revoke the old value, so the app can move over before the leaked one stops working. If secret scanning times out, GitHub can still accept the push and scan afterward, so a green push is not proof the key never left your machine.
The link in the error (unblock-secret) is how you allow the secret into the repository. That is the wrong button for a real API key.
The next error you'll probably hit
Once this is fixed, the usual follow-up is Rotate a leaked API key without taking the app down. Create the new key, point the host at it, redeploy, and prove a request works. Then revoke the old key. Revoking first is how production starts failing.
Prompt to paste back into your AI tool
Paste this above the error.
git push was rejected with: remote: error: GH013: Repository rule violations found remote: - Push cannot contain secrets The error names commit <sha> and path <file>. Do not open the unblock-secret URL. Do not tell me to push the secret and fix it later. Do not print the secret in the chat. Do not run git push --force unless these commits are already on the remote and I have said so. 1. Tell me to rotate the key first: create a new one, put it in the host env, redeploy, verify, then revoke the old one. 2. Remove the secret from <file> and read it from a gitignored env var. Add the env filename to .gitignore if it is missing. 3. If the secret is only in the latest unpushed commit, give me git commit --amend (not --all if other files are dirty) and then git push. 4. If it is in an earlier unpushed commit, give me the rebase -i steps from that commit, then git push. Do not rewrite unrelated files.
Common questions
+I deleted the key and the push still fails. Why?
Push protection scans every commit in the push. The error lists the commit that still contains the secret. A new commit on top does not remove it. Amend or rebase that commit, then push.
+The push was blocked, so the key never leaked. Can I skip rotation?
No. The block means this push did not update the branch. The value is still in your local commit, and it may be in the AI chat or an earlier host. Rotate it, then clean the commits so the next push succeeds.
+What is the unblock link in the error for?
It lets this secret into the repository. GitHub may ask you to say it is a test, a false positive, or that you will fix it later. A real API key is none of those. Remove it and rotate it.
Related errors
- Rotate a leaked API key without taking the app downCreate the new key, point the host at it, redeploy, and prove a request works. Then revoke the old key. Revoking first is how production starts failing.CursorLovableBoltOpenAIStripeOct 22, 2026
- git push rejected (fetch first)The remote branch has commits your branch does not. Git refused the push so those commits would not be discarded. A second message, refusing to merge unrelated histories, means the two repos never shared a commit.CursorLovableBoltNodeNext.jsOct 27, 2026
- NEXT_PUBLIC_ secret in the bundleA NEXT_PUBLIC_ or VITE_ secret is in the browser bundle. Rotate the key, move the call to a server route, and keep real public keys in the client.CursorLovableBoltNext.jsViteNov 11, 2026
- 401 Incorrect API key providedOpenAI rejected the key it received. Right after a rotation, the app is usually still sending the old value, a value with extra characters, or a key from the wrong project. Anthropic's matching failure is invalid x-api-key.CursorLovableBoltOpenAINext.jsOct 22, 2026