How can I distinguish untracked files from ignored files in Git status?
Quick answer
An untracked file normally appears in git status with ??. An ignored file is normally omitted; git status --ignored can show it with !!. If a file appears in neither place, do not assume it is ignored: Git configuration can suppress untracked-file reporting. Check the path with git check-ignore -v --non-matching <path> to see whether an ignore pattern matches and, if so, where it comes from. [S1] [S2]
The question, the details, the next step.
A practical checklist
Use the exact repository-relative path you are investigating.
Check ordinary
git statusfor the??untracked marker.Run
git status --ignoredand check for the!!ignored marker.Use
git check-ignore -v --non-matching <path>to inspect matching or non-matching ignore rules.If the path may be tracked, account for the default check behavior or use
--no-indexto test ignore rules.Do not conclude that a file is ignored solely because ordinary status omits it.
A few more useful answers
Does a missing file in ordinary `git status` mean Git is ignoring it?
What do `??` and `!!` mean in this investigation?
?? marks an untracked path in status output; !! marks an ignored path when ignored files are requested. [S1]
Why might `git check-ignore` say nothing for a path?
The path may match no ignore pattern, and a default check normally does not check tracked files. Use --non-matching to display non-matches, or --no-index when checking a tracked path against ignore rules. [S2]
Sources
References used for this guide.
- [S1] Git - git-status Documentation git-scm.com · Checked
- [S2] Git - git-check-ignore Documentation git-scm.com · Checked
