← Back to all fixes
Secret accidentally committed to Git
The Issue
You committed and pushed a file containing `AWS_SECRET=AKIAIOSFODNN7...` to GitHub.
Root Cause
.env or config file was not in .gitignore and was accidentally staged and committed.
How to Fix
FIRST: rotate the secret immediately — assume it is compromisedRemove from history: `git filter-repo --path .env --invert-paths` (install git-filter-repo)Force push the cleaned history: `git push --force --all`Add to .gitignore: `.env`, `*.pem`, `credentials.json`Use pre-commit hooks or tools like `gitleaks` to scan for secrets before every commitIf pushed to a public repo: GitHub will likely alert you via their secret scanning feature