What to do after committing an API key to GitHub

Revoke the credential with its issuer before rewriting Git history. Then remove copies and turn on scanning for future commits.

Example

A key appears in a public commit and is reverted ten minutes later. Someone may have fetched the original commit in that interval.

What to do

  1. Revoke the affected key, issue the replacement and update any workloads that used it.
  2. Review usage and access history. Record which branches, releases, build artifacts and pull requests contained the key.
  3. Follow your repository host's history cleanup guidance. Coordinate branch updates with collaborators, and configure secret scanning and push protection for supported key types.

How to verify

Provider activity shows the old key is disabled and the current branch, checks and published artefacts pass a secret scan.

Limits

Rewriting the repository cannot remove copies held by third parties.

Spendplane for this workflow

Try masking with fictional data

Related reading