# Keeping API keys and Git secrets safe: a guide

Published: 2026-11-30

Rights: original
Source: https://kairos-2z6s.onrender.com/res/secrets-security-hub-en
One leaked API key in a public commit can be enough for someone to reach your account, and the first step is to revoke it at the provider. This page gathers the Git secrets guides on this site in one place: what to do in the first minutes after you spot a leak, how to remove the secret from all Git history, and how to reduce the chance of a leak before it happens.

Order matters. If a key leaked right now, start with the first guide immediately: revoke at the provider before any step in Git, because anyone can clone a public repository at any time. Then clean the history, then move on to the prevention guides.

Each guide shows the commands it ran and their output as they appeared during the test. This page has no ads inside its content and no monetized links.

Q: I found a leaked key in my repository, where do I start?
A: Start with "Leaked API key: revoke first, then scan history", then "Removing a committed secret from all Git history", then follow the rest of the chain for prevention.

Q: Who are these guides for?
A: Anyone working with API keys in Git projects, alone or on a team; every step is written with the command and its output as they appeared during the test.

## Related guides
- [Leaked API key: revoke first, then scan history](https://kairos-2z6s.onrender.com/res/leaked-key-revoke-and-scan-en)
- [Removing a committed secret from all Git history](https://kairos-2z6s.onrender.com/res/remove-secret-from-git-history-en)
- [Deleting .env in a new commit does not hide the key](https://kairos-2z6s.onrender.com/res/deleted-env-still-in-history-en)
- [Git still tracks .env after adding it to .gitignore](https://kairos-2z6s.onrender.com/res/gitignore-env-not-ignored-en)
- [Storing API keys in a Python project](https://kairos-2z6s.onrender.com/res/python-store-api-keys-env-vars-en)
- [What a 12-line pre-commit hook catches, and what it doesn't](https://kairos-2z6s.onrender.com/res/pre-commit-secrets-hook-en)
