@readmodelmag
MODEL

Tools

We tested it: you deleted the API key, but git history kept it

SummaryWe committed a fake token, 'fixed' it with an env variable in the next commit, and ran gitleaks 8.30.1. A scan of the current files found nothing. A scan of the history found the token in commit 1, and a fresh clone still had it. A pre-commit hook stopped the next one.

· MODEL Editors · 2 min read

Some links may be affiliate links. Disclosure

MODEL builder tip card on a cream background. Small red kicker: WE TESTED IT / GIT SECRETS. Large red text: Commit 1. Black headline: You deleted the key. Git history kept it. Bottom left: MODEL. Bottom right: Sources: MODEL test, gitleaks 8.30.1, Nov 29 2026.
MODEL hands-on test of gitleaks 8.30.1 on a small test repo with a fake token, Nov 29, 2026. Illustration by MODEL. Original. Image source.

The problem. A coding agent wires up an API call and drops the key straight into the code. You spot it, move the key to an environment variable, commit again and move on. The file looks clean. The question is whether the key is gone.

What we ran. On Nov 29 we installed gitleaks 8.30.1 (free, open source, MIT license, about 31,000 GitHub stars) from its official GitHub release, checked the download against the published checksum, and built a tiny test repo with git 2.47.3. The "key" was a random string in GitHub personal-access-token format that we generated ourselves. It was never issued and works nowhere.

  • Commit 1: app.js with the fake token hardcoded in a fetch call.
  • Commit 2: the usual fix, process.env.GITHUB_TOKEN instead of the token.

No AI model, no network calls, no real credentials.

What we found.

  • Current files look clean. A plain text search of app.js found no token. gitleaks dir ., which scans files on disk, reported "no leaks found" and exited with code 0.
  • History doesn't. gitleaks git ., which scans every commit's changes (gitleaks' docs say it runs on git log -p), flagged the token as a GitHub personal access token in app.js, line 1, commit 1, and exited with code 1.
  • Every clone gets it. We cloned the repo fresh. The checked-out files had no token, but one git show of the first commit printed it in full.

What prevented the next one. We added gitleaks as a git pre-commit hook using the exact command from its official hook definition (gitleaks git --pre-commit --redact --staged --verbose), then staged a new file with a token in it. git commit failed with exit code 1, the commit was never created, and the output showed the secret as REDACTED.

The catch.

  • Hooks are opt-in and can be skipped. git commit --no-verify bypasses them, and gitleaks' README documents SKIP=gitleaks for the pre-commit framework. Running the same scan in CI covers what a laptop skips.
  • Rewriting history is not the fix on its own. GitHub's docs say that if the sensitive data is a secret, the first step is to revoke or rotate it. They also warn that after a history rewrite, old commits can still live in clones and forks, in cached views reachable by commit hash, and in pull requests that reference them.

Our verdict. gitleaks earns a pre-commit slot in any repo where an agent writes code. It is fast, local and exits non-zero, so it fails loudly. But a scanner is a seatbelt, not a fix: if a key ever reached a commit, rotate it. Deleting the line only hides it from you.

The tip.

  1. Scan history once: gitleaks git .. Scanning only the folder (gitleaks dir) misses old commits.
  2. Install the pre-commit hook, and run the same scan in CI.
  3. If anything real turns up, revoke or rotate the key first. Then decide whether to rewrite history using GitHub's guide.

Limits of our test. One tiny repo, one fake token in one well-known format, no real agent session. We did not test GitHub's push protection, history-rewrite tools, other secret types, other scanners or false-positive rates.

Disclosure: Tested by MODEL on Nov 29, 2026. Not sponsored. No affiliate links.

MODEL Editors

Get three tested tools every Friday

Free, weekly. Unsubscribe anytime.

Sources

  1. gitleaks/gitleaks (README, v8.30.1 release)

    GitHub

  2. gitleaks pre-commit hook definition

    GitHub

  3. Removing sensitive data from a repository

    GitHub Docs

FREE · EVERY WEEK

The top AI tools this week, tested.

Every week MODEL's editors pick the AI tools worth your time, try them hands-on, and tell you what's good, what's not, and who it's for. Free, in your inbox.

Free. Unsubscribe anytime. Our picks are editorial and can't be bought.