Glossary/Mistakes & leaks

Secret leaked in git history

A secret leaked in git history means a key or password was committed at some point, and even though a later commit may delete or replace it, the original value remains readable in the repository's history unless that history is explicitly rewritten.

Why it matters

Anyone who clones the repository, or who has access to it on a platform like GitHub, can check out an old commit or search the history to find the original value, regardless of what the current files show.

Does deleting the file remove the secret from git?

No, not from history. The old commit still contains it, and the only reliable fix is revoking the exposed value.

Can I rewrite git history to remove a secret?

Yes, with tools built for that, but it rewrites commit hashes for everyone with the repository, which is disruptive and does not undo a leak that already happened.

Related

Looking for a different way to manage your keys? See the best Claude Code API key manager alternatives, or browse every term in the glossary.