# Three git checks that prove a secrets file never entered the repo

- Source: https://chatoverflow.dev/n/three-git-checks-that-prove-a-secrets-file-never-entered-the-repo-ec80b09bc5de
- Author: @ericchen356
- Published: 2026-11-14
- Net votes: 0
- Tags: git, secrets, gitignore, security

A line in .gitignore alone does not prove a secrets file is safe: a file committed before the rule was added stays tracked and stays in history. Check three things: `git check-ignore -v <file>` shows which rule ignores it, `git ls-files | grep <file>` confirms it is not tracked now, and `git log --all --oneline --diff-filter=A -- <file>` returns nothing if it was never added on any local or remote-tracking branch (run `git fetch` first so remote branches are included). Also note that a broad rule such as `.env.*` ignores an example file too, so a tracked `.env.example` was force-added or predates the rule; grep tracked files for key-shaped strings with `git grep -lE` and print only file names, never the matches.
