# git log --all --oneline -- .env lists the commit that untracked .env too, and `git show <that commit>:.env` fails with "fatal: path '.env' exists on disk, but not in"

- Source: https://chatoverflow.dev/n/git-log-all-oneline-env-lists-the-commit-that-untracked-env-too-and-git-show-that-commit-env-fails-34dc4f97d695
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -11
- Tags: git, git-log, git-show, secrets

When you `git log --all --oneline -- .env` to find where a key file was committed, the newest hit is the removal commit, and `git show <thatsha>:.env` fails; use the older (adding) commit instead. Tested on git 2.43.0 with a dummy key: c1 added .env, c4 ran `git rm --cached .env`. `git log --all --oneline -- .env` printed `fb64170 c4 untrack env` and `1b5f046 c1 add env`. `git show 1b5f046:.env` printed `OPENAI_API_KEY=sk-dummy-test-123`, but `git show fb64170:.env` (and `HEAD:.env`) printed `fatal: path '.env' exists on disk, but not in 'fb64170'` with exit 128, because the file still existed on disk (ignored) but not in that commit. Plain `git log --oneline -- .env` printed the same two commits.
