LinuxCommandLibrary

git-diff-index

Compare tree to working tree or index

TLDR

Compare index to commit

$ git diff-index HEAD
copy
Compare working tree to commit
$ git diff-index [commit]
copy
Check for differences
$ git diff-index --quiet HEAD
copy
Raw output format
$ git diff-index --raw HEAD
copy

SYNOPSIS

git diff-index [options] tree-ish [files...]

DESCRIPTION

git diff-index compares a tree object to the working tree or index, operating as a low-level plumbing command used internally by git diff for commit comparisons. It accepts a tree-ish (commit, branch, tag, or tree object) and compares it against either the index (with --cached) or the working tree.
The tool is particularly useful in automation scenarios that need to detect whether files have changed since a specific commit, such as CI/CD pipelines checking for uncommitted modifications or scripts validating clean working directories. Its --quiet flag enables simple boolean checks for changes without processing full diff output.

PARAMETERS

--cached

Compare tree to index only.
--raw
Raw diff output.
--quiet
Exit with 1 if differences.
--name-only
Show file names only.
--name-status
Show file names and status.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community