Skip to content
Latchkey

git ls-files: Usage, Options & Common CI Errors

git ls-files shows which files are in the index - and, with flags, which are untracked or modified.

ls-files is plumbing for "what does Git see here". It is the precise way to enumerate tracked or untracked paths.

What it does

git ls-files prints the names of files registered in the index. Flags expand it to show untracked, modified, ignored, or stage-conflicted files.

Common usage

Terminal
git ls-files                      # all tracked files
git ls-files --others --exclude-standard   # untracked (respecting .gitignore)
git ls-files --modified           # changed tracked files
git ls-files --error-unmatch path # exit non-zero if not tracked

Options

FlagWhat it does
--others / -oShow untracked files
--exclude-standardApply .gitignore and friends
--modified / -mShow modified tracked files
--cached / -cShow staged files (default)
--error-unmatchError if a given path is not tracked

Common errors in CI

error: pathspec 'X' did not match any file(s) known to git (with --error-unmatch) is the intended signal that a path is not tracked - useful as a guard. Note --others alone includes ignored files; add --exclude-standard to honor .gitignore.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →