Skip to main content

How to See Ignored Files in Git with git status --ignored

· 3 min read
Jagdish Kumawat
Founder @ Dewiride

A .gitignore file keeps files out of Git, but plain git status never mentions them, so you can't tell whether your rules really match. git status --ignored adds them to the list. It's the quickest way to check a .gitignore before the first commit. This guide uses it on Git 2.56.1.

Syntax​

Syntax
git status --ignored
git status --short --ignored
PartWhat it means
--ignoredAlso list the files and folders that Git ignores
--shortOne line per entry: ?? for untracked, !! for ignored

The git status documentation describes --ignored as "Show ignored files as well", and says that in the short format "ignored files are indicated by !!".

The Example​

A new repository holds app.py, a cache folder, a debug.log file, and a .gitignore with two rules:

.gitignore
cache/
*.log

Step 1: Look at the Normal Status​

Terminal
git status --short
Output
?? .gitignore
?? app.py

Only the two files Git would add are listed. cache/ and debug.log don't appear at all, which looks right but proves nothing.

Step 2: Add the Ignored Files​

Terminal
git status --short --ignored
Output
?? .gitignore
?? app.py
!! cache/
!! debug.log

The terminal after git status --short --ignored: .gitignore and app.py marked ??, and cache/ and debug.log marked !!.

Now the ignored entries show up, marked !!: the folder through cache/ and the log through *.log. Both rules work.

Step 3: The Long Format​

Terminal
git status --ignored
Output
On branch main

No commits yet

Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
app.py

Ignored files:
(use "git add -f <file>..." to include in what will be committed)
cache/
debug.log

nothing added to commit but untracked files present (use "git add" to track)

The long format gives the ignored entries a section of their own, Ignored files. The hint under it, git add -f, is how you would add an ignored file on purpose. The commands work unchanged in PowerShell.

Common Mistakes​

MistakeWhat happensDo this instead
Trusting plain git status to check a .gitignoreIgnored and missing files look the same: absentCheck with --ignored
Expecting a file Git already tracks to show as ignored.gitignore only affects untracked files, so a tracked file stays trackedStop tracking it with git rm --cached <file>

Troubleshooting​

SymptomLikely causeFix
A file you meant to ignore shows ?? instead of !!The pattern doesn't match itFix the pattern, then check again
A file shows !! that you want to commitA rule matches itNarrow the rule, or add the file with git add -f

FAQ​

What do ?? and !! mean?​

?? is an untracked file Git would add with git add .. !! is a file Git ignores because of a rule.

Does --ignored change anything?​

No. It only lists more. Your repository and .gitignore stay as they are.

Conclusion​

git status --short listed only .gitignore and app.py, and --ignored added cache/ and debug.log marked !!, proving both rules matched. Run it whenever you change a .gitignore.

Additional Resources​

  • git status — --ignored and its modes, and the short format.
  • gitignore — how patterns match.