Keep secrets out of source control
Store credentials in an approved secret manager or deployment environment. Use example configuration files with placeholder values. Add secret files to ignore rules and review the repository before a push.
Secret scanning can find known patterns, but it may miss a custom token or encoded value. Review changes to configuration and test data before publishing a repository.
Rotate first when a real secret leaks
Revoke or rotate an exposed credential. Deleting the line from the latest file does not remove it from Git history, forks, caches or downloaded copies.
Check logs for use of the credential and review the permissions it had. If it could access customer data or production systems, follow the incident process.
Prevent the next exposure
Use separate credentials for development and production. Set narrow permissions and expiration dates. Give each credential an owner who can renew or revoke it.
Add secret scanning to the repository workflow and make it easy for developers to request a safe test credential. Rewriting Git history should not replace credential rotation.
