Skip to content

diff-files Git Command Guide

The git diff-files command compares the files in the working directory against the files in the index (staging area). It shows the differences between what’s been modified in the working directory and what’s been staged.

Terminal window
git diff-files [<options>] [--] [<path>...]
OptionDescription
-0Omit diff output for unmerged entries
-1, -2, -3Diff against (stage 1), (stage 2), or (stage 3) for unmerged paths
—baseDiff against merge base for unmerged paths
—oursDiff against our side for unmerged merge paths
—theirsDiff against their side for unmerged merge paths
—diff-filter=[(AC
—no-renamesTurn off rename detection
—relative[=]Generate relative diffs
—stat[=[,[,]]]Generate a diffstat
—compact-summaryGenerate compact summary of extended header information
—numstatShow added/deleted line counts
—shortstatOutput only the last line of —stat format
—patch, -p, -uGenerate patch (default)
—no-patch, -sSuppress diff output
—patch-with-statAlias for —stat —patch, -p
—name-onlyShow only names of changed files
—name-statusShow only names and status of changed files
—output=Output to a specific file
—output-indicator-new=Specify the character to indicate new lines in —output
—output-indicator-old=Specify the character to indicate old lines in —output
—output-indicator-context=Specify the character to indicate context lines in —output
—verbosity=Control amount of output
—progressForce progress reporting
—color[=]Show colored diff
—no-colorTurn off colored diff
—color-moved[=]Color moved lines
—color-moved-ws=Configure color-moved whitespace
—no-color-movedTurn off color-moved
—color-words[=]Color words in changed lines
—word-diff[=]Show word diff
—word-diff-regex=Use to determine what constitutes a word
—ignore-all-space, -wIgnore whitespace when comparing lines
—ignore-space-change, -bIgnore changes in amount of whitespace
—ignore-space-at-eolIgnore changes in whitespace at EOL
—ignore-blank-linesIgnore changes whose lines are all blank
—ignore-cr-at-eolIgnore CR at EOL when doing a comparison
—ignore-whitespace-at-eol, -bIgnore whitespace at EOL
—indent-heuristic, —no-indent-heuristicEnable/disable indent heuristic
—textconv, —no-textconvAllow/disallow external text conversion filters
—binaryOutput a binary diff instead of a text diff
—abbrev[=]Show the shortest prefix that is at least hexdigits long
—full-indexShow full pre- and post-image blob object names
—break-rewrites[=[/]], -B[[/]]Break complete rewrite changes into pairs
—find-renames[=], -M[]Detect renames
—find-copies[=], -C[]Detect copies
—find-copies-harderTry harder to find copies
—irreversible-delete, -DOmit the preimage for deletes
—pickaxe-all, -S Look for differences that change the number of occurrences of the specified string
—pickaxe-regex, -S Look for differences that change the number of occurrences
—minimalSpend extra time to make smallest possible diff
—patienceGenerate diffs by using patience algorithm
—histogramGenerate diffs by using histogram algorithm
—diff-algorithm={patienceminimal
—anchored=Generate diffs by using anchored algorithm
—diff-merges=(offnone
—exit-codeMake diff exit with codes similar to diff(1)
—quiet, -qDisable all output
—ext-diffAllow an external diff helper to be executed
—no-ext-diffDisallow external diff helpers
—textconvAllow external textconv filters to be run
—no-textconvDisallow external textconv filters
—ignore-submodules[=]Ignore changes to submodules
—src-prefix=Use instead of “a/”
—dst-prefix=Use instead of “b/”
—no-prefixDo not show any source or destination prefix
—line-prefix=Prepend an additional prefix to every line
—ita-invisible-in-indexHide ‘git add -N’ entries from short format
—gitUse git-style output format
—no-indexCompare two files not in a Git repository
ParameterDescription
Restrict diff to specific files or directories
Terminal window
git diff-files

Shows all differences between working directory and index.

Terminal window
git diff-files file1.txt file2.js

Shows differences only for specified files.

Terminal window
git diff-files --name-only

Lists only the names of files that differ.

Terminal window
git diff-files --name-status

Shows names and modification status of changed files.

Terminal window
git diff-files --stat

Shows summary statistics of changes.

Terminal window
git diff-files -- file1.txt dir/file2.txt

Double dash separates options from paths to compare.

Terminal window
git diff-files -w

Shows differences ignoring whitespace changes.

Terminal window
git diff-files --word-diff

Highlights individual word changes within lines.

Terminal window
git diff-files --exit-code

Returns exit code 1 if there are differences, 0 if identical.

Terminal window
git diff-files --compact-summary

Shows a compact summary of all changes.

Terminal window
git diff-files --no-index file1 file2

Compare two arbitrary files outside repository.

How do I see differences between working directory and index?

Section titled “How do I see differences between working directory and index?”

To see differences between working directory and index, use:

Terminal window
git diff-files

How can I see only the names of changed files?

Section titled “How can I see only the names of changed files?”

To see only the names of changed files, run:

Terminal window
git diff-files --name-only

To get a summary of changes, execute:

Terminal window
git diff-files --stat

To compare specific files, use:

Terminal window
git diff-files <file1> <file2>

To see the status of changed files, run:

Terminal window
git diff-files --name-status

Applications of the git diff-files command

Section titled “Applications of the git diff-files command”
  1. Reviewing changes before staging files for commit
  2. Checking what modifications remain uncommitted
  3. Analyzing merge conflicts at the file level
  4. Debugging file changes during development
  5. Preparing selective commits with targeted file reviews
  6. Monitoring work in progress status