Recent chats
ASKGEEZ Q&A GUIDETechnology & devices

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]

LET’S WORK THROUGH IT

The question, the details, the next step.

Question

I created a file, but it does not show up in my usual git status output. How do I tell whether it is untracked or ignored?

Geez

Look for two different signs. An untracked path normally appears as ?? in status output. An ignored path is usually omitted from ordinary status; ask Git to include ignored files with git status --ignored, where ignored entries are marked !!. [S1]

For example, if the hypothetical file is notes/draft.txt, run:

git status
git status --ignored

If notes/draft.txt appears with ??, it is untracked. If it appears with !!, Git is reporting it as ignored. If it appears in neither output, that still does not prove it is ignored: configuration can suppress untracked-file reporting. [S1]

Follow-up question

The file is still hard to spot in the output. How can I check whether an ignore rule is responsible?

Geez

Ask Git to check the exact path and show the matching rule, if there is one:

git check-ignore -v notes/draft.txt

When the path matches an ignore pattern, verbose output identifies the source and pattern responsible. [S2] That helps distinguish, for instance, a rule matching *.txt from one aimed only at a particular directory. These are hypothetical examples: the command’s output tells you what applies in your repository.

A path that produces no report by default is not necessarily ignored. To also make non-matching paths visible, use verbose output with --non-matching:

git check-ignore -v --non-matching notes/draft.txt

A non-match means this check did not find an ignore pattern for that path; it does not, by itself, explain why ordinary status omitted it. [S2]

Follow-up question

What if git check-ignore does not report the file? Could it already be tracked?

Geez

Possibly. Git normally does not check tracked files with git check-ignore; the command has a --no-index option for checking them anyway. [S2] So a quiet result is not proof that the file is ignored, and for a tracked path the default check may not be informative.

If you specifically need to test a tracked path against ignore patterns, try:

git check-ignore -v --no-index notes/draft.txt

Use this to investigate the ignore rule, not as a substitute for understanding the file’s tracking state. The command’s result describes whether an ignore pattern matches; it does not establish why a particular file is absent from your status output. [S2]

Follow-up question

How should I interpret a result where the file is absent from status and no ignore pattern matches?

Geez

Treat each result as evidence about one question, not as a complete diagnosis. For a hypothetical notes/draft.txt, you might record:

Ordinary status: absent
Status with --ignored: absent
check-ignore: no matching pattern
Tracking status: not yet established

This rules out a matching ignore pattern in that check, but does not explain the status output or prove the file’s tracking state. Configuration can suppress untracked-file reporting, and the default ignore check normally skips tracked paths. [S1] [S2]

Keep the path and command results together as you investigate. If you need to check a potentially tracked path against ignore rules, use --no-index; otherwise, do not infer more from an absent or non-matching result than the command establishes.

A practical checklist

  • Use the exact repository-relative path you are investigating.

  • Check ordinary git status for the ?? untracked marker.

  • Run git status --ignored and 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-index to 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?

No. Ignored paths are omitted by default, but configuration can also suppress untracked-file reporting. Use ignored status and an ignore check to gather more evidence. [S1] [S2]

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.

  1. [S1] Git - git-status Documentation
    git-scm.com · Checked
  2. [S2] Git - git-check-ignore Documentation
    git-scm.com · Checked

YOUR QUESTION. YOUR DETAILS.

Let’s work through your situation.

Get a tailored answer or help with your next task. Starts at $1, with a quote before you pay.

Ask your own question
← Back to Geez at Work