Fix GitHub Error 'remote: error: GH013: Repository rule violations found — Push cannot contain secrets'
Scan and scrub accidentally committed API keys or tokens from your Git commit history using Castov Secret Scanner and `git reset`.
remote: error: GH013: Repository rule violations found for refs/heads/main. - Push cannot contain secrets
# 1. Scan all files locally (100% offline) to locate every leaked token: npx castov scan . # 2. Undo the last 1 local commit(s) while keeping your working tree changes: git reset --soft HEAD~1 # 3. Rotate the compromised key or generate a new cryptographic secret: npx castov secret 32
Root Cause & Mechanism Analysis
Why does this error occur?
GitHub Push Protection detected a live credential pattern (such as an AWS key, Stripe secret, or OpenAI token) inside one of the commits being pushed—even if you deleted the secret in a later commit.
Frequently Asked Questions
How do I prevent GH013 before committing?
Need Zero-Knowledge .env Secret Sync Across Your Engineering Team?
Explore Castov Env Vault for client-side AES-256-GCM encrypted environment sharing, or sponsor this engineering hub.
Related Developer Error Solutions
Browse All 54 GuidesDocker: no space left on device
Clean dangling Docker build caches, unused volumes, and stopped containers to free disk space.
Next.js Hydration Failed
Resolve Next.js React hydration mismatch errors caused by browser-only APIs (window, localStorage), timestamps, or invalid HTML nesting.
CORS 'Access-Control-Allow-Origin' Missing
Resolve browser cross-origin resource sharing errors by configuring backend HTTP headers and handling preflight OPTIONS requests.
Docker: Bind for 0.0.0.0:Port Failed
Identify and terminate conflicting host processes or adjust Docker port mapping to resolve port bind collisions.