LinuxCommandLibrary

git-diff-files

Show changes between the index and filesystem

TLDR

Compare all changed files

$ git diff-files
copy

Compare only specified files
$ git diff-files [path/to/file]
copy

Show only the names of changed files
$ git diff-files --name-only
copy

Output a summary of extended header information
$ git diff-files --summary
copy

SYNOPSIS

git diff-files [options] [--] [pathspec…]

PARAMETERS

-p, --patch, -u, --unified
    Generate unified diff output instead of summaries

--name-only
    Show only names of changed files

--name-status
    Show names and status (e.g., added, modified)

--diff-filter=(ABCDMRTUX*)
    Filter diffs by status codes (Added, Deleted, etc.)

-R, --reverse
    Swap input/output sides of diff

-r, --recursive
    Handle subdirectories recursively

--relative
    Paths relative to current directory

--no-index
    Compare two directories (non-Git mode)

--quiet, -q
    Exit with non-zero if differences found, no output

-z
    Use NUL as pathname separator

--find-renames[=]
    Detect renames (threshold n/100)

--base
    Use base version for three-way merge diffs

--ours, --theirs
    Use our/their version in merge diffs

--slot[=]
    Pick slot n (1-3) from index

DESCRIPTION

git diff-files is a low-level Git plumbing command that displays differences between files in the working tree and the index (staging area). By default, it produces a unified diff format showing added (+), removed (-), and modified lines.

This command is useful for scripts and internal Git operations, such as checking staged changes without committing. It ignores untracked files and only examines tracked ones. Specify paths to limit output to specific files or directories.

Unlike git diff (which compares working tree to HEAD), git diff-files focuses solely on index vs. working tree. For user-facing use, prefer porcelain commands like git diff --cached. Output is machine-parsable but may evolve, so avoid direct parsing in production scripts.

CAVEATS

Plumbing command; output format unstable, prefer git diff --cached for scripts. Ignores untracked files. No color by default unless GIT_DIFF_OPTS set.

EXIT STATUS

0 if no differences; 1 if differences found; >1 on errors.

EXAMPLES

git diff-files — show all staged changes.
git diff-files --name-only README.md — changed files matching path.

HISTORY

Introduced in Git 0.99 (2005) as core plumbing tool. Evolved with diff engine improvements; largely unchanged but overshadowed by porcelain git diff since Git 1.5 (2007).

SEE ALSO

Copied to clipboard