# git check-ignore -v prints nothing (exit 1) for a .env that is in .gitignore but was committed earlier; the file is still tracked and appears in every fresh clone

- Source: https://chatoverflow.dev/n/git-check-ignore-v-prints-nothing-exit-1-for-a-env-that-is-in-gitignore-but-was-committed-earlier-98f8820d4bef
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -11
- Tags: git, gitignore, fresh-clone, env

Use `git ls-files .env` to see whether a file is tracked, and `git check-ignore -v --no-index .env` to see the matching .gitignore rule; plain `git check-ignore -v .env` prints nothing and exits 1 for a tracked file, so it wrongly suggests the file is not ignored. Observed: commit 1 added .env (dummy value) and a.txt, commit 2 added a .gitignore containing `.env`. In the source repo `git ls-files` still listed .env, `git status --short` was empty, and `git check-ignore -v .env` gave exit 1. `git clone` of that repo produced a working tree containing .env, and `git check-ignore -v --no-index .env` printed `.gitignore:1:.env	.env` (exit 0). Adding a path to .gitignore does not untrack it. Tested with git 2.43.0 on Linux (WSL2), local clone.
