git-ls-files
List files tracked by Git
TLDR
Show deleted files
Show modified and deleted files
Show ignored and untracked files
Show untracked files, not ignored
SYNOPSIS
git ls-files [options] [--] [pathspec...]
PARAMETERS
-c, --cached
Show files from the index (default unless -d, -o, or -m given)
-d, --deleted
Show files deleted from index but present in working tree
-m, --modified
Show files modified since last commit (cached or not)
-o, --others
Show untracked files (use with --exclude-standard)
-i, --ignored
Show only ignored files (requires --others)
-t
Prepend file type indicator (H=valid, ? = unmerged, etc.)
-u, --unmerged
Show unmerged entries in index
-k, --killed-files-only
Show only files to be removed from index (deprecated)
-x, --exclude=pattern
Exclude files matching pattern
-X, --exclude-from=file
Exclude patterns from file
--exclude-per-directory=file
Read excludes from file in each directory
--exclude-standard
Add standard ignores (.git/info/exclude, .gitignore, etc.)
-z
Terminate entries with NUL, not newline
--eol[=diag]
Show line ending diagnostics (i/m/w/i/m)
-s, --stage
Show stage files (mode, object name, stage number)
--unmerged
Same as -u
--with-tree=tree-ish
Compare index against given tree
--full-name
Force paths relative to top-level directory
--error-unmatch
Exit with error if any pathspec unmatched
--recurse-submodules
Recurse into submodules
-v, --verbose
Add extra details (like git status)
--debug
More verbose debug output
--short
Emit paths relative to root in short format
DESCRIPTION
The git ls-files command displays information about files in the Git index (staging area) and working directory. By default, it lists all files currently tracked in the index, making it useful for scripting, build systems, or inspecting repository state.
Key uses include:
• Listing staged files with --cached (default).
• Detecting modified files (-m), deleted files (-d), or untracked files (-o).
• Showing ignored files (-i) or unmerged entries (-u).
• Outputting stage information (-s) for conflicted files or file types (-t).
It supports pathspecs to filter output and options like --exclude-standard for .gitignore patterns. The output is stable and parseable, ideal for automation. Unlike git status, it provides machine-friendly details without human-readable summaries. Combine with --with-tree to compare against a specific tree-ish.
This command is efficient, scanning only the index and working tree without full repository traversal.
CAVEATS
Paths are relative to current directory unless --full-name; output order is not guaranteed; use -z for safe parsing in scripts; does not respect .git/info/exclude-standard without --exclude-standard.
COMMON EXAMPLES
git ls-files --others --exclude-standard
Lists untracked files ignoring .gitignore.
git ls-files --modified --exclude-standard
Shows modified tracked files.
git ls-files -s
Lists staged files with blob modes and hashes.
EXIT STATUS
0 if all pathspecs matched or no paths given; 1 if unmatch with --error-unmatch; 128+ for fatal errors.
HISTORY
Introduced in Git 0.99 (2005) as core plumbing command; evolved with options like --exclude-standard (v1.3, 2006) and submodule support (v1.8.2, 2013); remains stable for backward compatibility in Git 2.x series.
SEE ALSO
git status(1), git diff --name-only(1), git ls-tree(1), find(1)


