🌿Push blocked because it contains a secret key
remote: error: GH013: Repository rule violations found … Push cannot contain secrets
The code you're uploading contains a secret value like an API key, so GitHub blocked it for you. This is a helpful error.
🤔 Why does it happen?
- An API key was written directly in the code or a .env file and committed
🔧 Try this
- Treat that key as already exposed: revoke it in the service and get a new one
- Keep keys only in .env.local and add it to .gitignore
- Ask the AI how to remove the key from the commit history
🤖 Ask your AI like this
My git push was blocked with 'Push cannot contain secrets'. Please tell me the steps to remove the secret key from the code and the commit history, move it to an environment variable, and set up .gitignore. Don't ask me for the key's value.
Replace the [ ] parts with your own situation, and paste the error with a few extra lines before and after it.
Related terms
Other errors in this group
- Push rejected
failed to push some refs (rejected) - Merge conflict
CONFLICT (content): Merge conflict - GitHub authentication failed
Permission denied (publickey) - Not a git repository
fatal: not a git repository - Can't combine two different histories
fatal: refusing to merge unrelated histories - File too big to upload to GitHub
File exceeds GitHub's file size limit of 100.00 MB