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 [--quiet] [--ignore-space-change] [--ignore-all-space] [--ignore-blank-lines] [--find-renames=] [--raw] [--patch] [--stat] [--summary] [--name-only] [--name-status] [--abbrev=] [--no-ext-diff] [--text] [--no-textconv] [--ignore-submodules[=]] [--relative[=]] [--src-prefix=] [--dst-prefix=] [--line-prefix=] [-z] [--] [...]

PARAMETERS

--quiet
    Do not output anything, just set the exit status based on whether changes were found.

--ignore-space-change
    Ignore changes in amount of whitespace.

--ignore-all-space
    Ignore whitespace when comparing lines.

--ignore-blank-lines
    Ignore changes whose lines are all blank.

--find-renames=
    Detect renames, optionally setting the similarity index threshold.

--raw
    Output in raw format.

--patch
    Generate patch format output.

--stat
    Generate diffstat-style output.

--summary
    Output a condensed summary of extended header information such as file creations or deletions.

--name-only
    Show only names of changed files.

--name-status
    Show only names and status of changed files.

--abbrev=
    Abbreviate object names to digits.

--no-ext-diff
    Disallow external diff drivers.

--text
    Treat all files as text.

--no-textconv
    Do not allow text conversion filters to be run.

--ignore-submodules[=]
    Ignore changes to submodules, the clause can be 'none', 'untracked', 'dirty', 'all' or is equal to the config setting 'diff.ignoreSubmodules'.

--relative[=]
    Display the path as relative to the given path. If no path is specified, display the path relative to the top of the working tree.

--src-prefix=
    Show the given source prefix instead of "a/".

--dst-prefix=
    Show the given destination prefix instead of "b/".

--line-prefix=
    Prepend an additional prefix to every line of output.

-z
    Separate file names with NUL characters.

--
    Marks the end of options; subsequent arguments are treated as file names.

...
    Limit the diff to the specified files or directories.

DESCRIPTION

The git-diff-files command is a plumbing command in Git that compares the indexed files (staging area) against the files in the working directory. It identifies differences that have been made to the files tracked by Git but haven't yet been added to the staging area using git add. This is useful for checking what modifications you've made since the last time you staged your changes. Unlike git diff without arguments, git-diff-files does not involve the commit history; it strictly compares the index (staging area) content with your working directory files. The command outputs a patch-like format detailing the added, deleted, or modified lines between the two versions. This facilitates reviewing changes before adding them to the index.

CAVEATS

This command operates directly on the filesystem and the index. Therefore, it's essential to understand that changes made directly to files in the working directory that haven't been staged will be reflected in the output. Also, because this command works on the file system, permission changes will show up in the output as well.

EXIT STATUS

The command exits with non-zero status if any differences are found; otherwise, it exits with zero status, unless the --quiet option is used.

SEE ALSO

Copied to clipboard