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.
git diff-files Syntax:
Section titled “git diff-files Syntax:”git diff-files [<options>] [--] [<path>...]Options:
Section titled “Options:”| Option | Description |
|---|---|
| -0 | Omit diff output for unmerged entries |
| -1, -2, -3 | Diff against (stage 1), (stage 2), or (stage 3) for unmerged paths |
| —base | Diff against merge base for unmerged paths |
| —ours | Diff against our side for unmerged merge paths |
| —theirs | Diff against their side for unmerged merge paths |
| —diff-filter=[(A | C |
| —no-renames | Turn off rename detection |
| —relative[= | Generate relative diffs |
| —stat[= | Generate a diffstat |
| —compact-summary | Generate compact summary of extended header information |
| —numstat | Show added/deleted line counts |
| —shortstat | Output only the last line of —stat format |
| —patch, -p, -u | Generate patch (default) |
| —no-patch, -s | Suppress diff output |
| —patch-with-stat | Alias for —stat —patch, -p |
| —name-only | Show only names of changed files |
| —name-status | Show 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 |
| —progress | Force progress reporting |
| —color[= | Show colored diff |
| —no-color | Turn off colored diff |
| —color-moved[= | Color moved lines |
| —color-moved-ws= | Configure color-moved whitespace |
| —no-color-moved | Turn off color-moved |
| —color-words[= | Color words in changed lines |
| —word-diff[= | Show word diff |
| —word-diff-regex= | Use |
| —ignore-all-space, -w | Ignore whitespace when comparing lines |
| —ignore-space-change, -b | Ignore changes in amount of whitespace |
| —ignore-space-at-eol | Ignore changes in whitespace at EOL |
| —ignore-blank-lines | Ignore changes whose lines are all blank |
| —ignore-cr-at-eol | Ignore CR at EOL when doing a comparison |
| —ignore-whitespace-at-eol, -b | Ignore whitespace at EOL |
| —indent-heuristic, —no-indent-heuristic | Enable/disable indent heuristic |
| —textconv, —no-textconv | Allow/disallow external text conversion filters |
| —binary | Output a binary diff instead of a text diff |
| —abbrev[= | Show the shortest prefix that is at least |
| —full-index | Show full pre- and post-image blob object names |
| —break-rewrites[= | Break complete rewrite changes into pairs |
| —find-renames[= | Detect renames |
| —find-copies[= | Detect copies |
| —find-copies-harder | Try harder to find copies |
| —irreversible-delete, -D | Omit 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 |
| —minimal | Spend extra time to make smallest possible diff |
| —patience | Generate diffs by using patience algorithm |
| —histogram | Generate diffs by using histogram algorithm |
| —diff-algorithm={patience | minimal |
| —anchored= | Generate diffs by using anchored algorithm |
| —diff-merges=(off | none |
| —exit-code | Make diff exit with codes similar to diff(1) |
| —quiet, -q | Disable all output |
| —ext-diff | Allow an external diff helper to be executed |
| —no-ext-diff | Disallow external diff helpers |
| —textconv | Allow external textconv filters to be run |
| —no-textconv | Disallow external textconv filters |
| —ignore-submodules[= | Ignore changes to submodules |
| —src-prefix= | Use |
| —dst-prefix= | Use |
| —no-prefix | Do not show any source or destination prefix |
| —line-prefix= | Prepend an additional prefix to every line |
| —ita-invisible-in-index | Hide ‘git add -N’ entries from short format |
| —git | Use git-style output format |
| —no-index | Compare two files not in a Git repository |
Parameters:
Section titled “Parameters:”| Parameter | Description |
|---|---|
| Restrict diff to specific files or directories |
git diff-files Command Samples:
Section titled “git diff-files Command Samples:”Show all differences
Section titled “Show all differences”git diff-filesShows all differences between working directory and index.
Show differences for specific files
Section titled “Show differences for specific files”git diff-files file1.txt file2.jsShows differences only for specified files.
Show only file names
Section titled “Show only file names”git diff-files --name-onlyLists only the names of files that differ.
Show status of changed files
Section titled “Show status of changed files”git diff-files --name-statusShows names and modification status of changed files.
Show statistics
Section titled “Show statistics”git diff-files --statShows summary statistics of changes.
Compare specific files
Section titled “Compare specific files”git diff-files -- file1.txt dir/file2.txtDouble dash separates options from paths to compare.
Ignore whitespace changes
Section titled “Ignore whitespace changes”git diff-files -wShows differences ignoring whitespace changes.
Show word differences
Section titled “Show word differences”git diff-files --word-diffHighlights individual word changes within lines.
Exit with status
Section titled “Exit with status”git diff-files --exit-codeReturns exit code 1 if there are differences, 0 if identical.
Compact summary
Section titled “Compact summary”git diff-files --compact-summaryShows a compact summary of all changes.
Generate patch
Section titled “Generate patch”git diff-files --no-index file1 file2Compare 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:
git diff-filesHow 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:
git diff-files --name-onlyHow do I get a summary of changes?
Section titled “How do I get a summary of changes?”To get a summary of changes, execute:
git diff-files --statHow can I compare specific files?
Section titled “How can I compare specific files?”To compare specific files, use:
git diff-files <file1> <file2>How do I see the status of changed files?
Section titled “How do I see the status of changed files?”To see the status of changed files, run:
git diff-files --name-statusApplications of the git diff-files command
Section titled “Applications of the git diff-files command”- Reviewing changes before staging files for commit
- Checking what modifications remain uncommitted
- Analyzing merge conflicts at the file level
- Debugging file changes during development
- Preparing selective commits with targeted file reviews
- Monitoring work in progress status