GIT-DIFF-INDEX(1) Git Manual GIT-DIFF-INDEX(1) (NAME) git-diff-index - (SYNOPSIS) git diff-index [-m] [-ached] [--merge-base] [<-->] [<>...] (DESCRIPTION) blob . <> . . (OPTIONS) -p, -u, --patch ( " P- (GENERATING PATCH TEXT WITH -P)"). -s, --no-patch diff. git show --patch --stat (alias) . -U, --unified= diff (context). diff.context . (-U -p ). --patch . --output= (stdout). --output-indicator-new=, --output-indicator-old=, --output-indicator-context= . + - ' ' . --raw (raw). . --patch-with-raw -p --raw. --indent-heuristic (heuristic) diff . . --no-indent-heuristic (indent heuristic). --minimal diff . --patience diff <>. --histogram diff <>. --anchored= diff <>. . . <> . --diff-algorithm=(patience|minimal|histogram|myers) diff. : default, myers diff. . minimal diff . patience <> . histogram patience << >> . diff.algorithm --diff-algorithm=default . --stat[=[,[,]]] diffstat. . . diff.statNameWidth= . --stat-graph-width= diff.statGraphWidth= . --stat --stat-graph-width (stat graph) diff.statNameWidth diff.statGraphWidth git format-patch . ... . --stat-width= --stat-name-width= --stat-count= . --compact-summary ("new" "gone" +l) (+x -x ) diffstat. . --stat . --numstat --stat . 0 0 - . --shortstat --stat . -X [,...], --dirstat[=,...] . --dirstat . diff.dirstat ( git-config(1) ). : changes dirstat . . . . lines dirstat diff /. ( ). --dirstat changes . --*stat . files dirstat . dirstat . --dirstat . cumulative . cumulative . () noncumulative . ( ) . . : : --dirstat=files,10,cumulative. --cumulative --dirstat=cumulative. --dirstat-by-file[=,...] --dirstat=files,,.... --summary / (mode). --patch-with-stat -p --stat. -z --raw --numstat --name-only --name-status NUL . <<>> core.quotePath (quote) ( git-config(1) ). --name-only (post-image). UTF-8 . git-log(1) . --name-status ( ) . --diff-filter . --name-only UTF-8 . --submodule[=] (submodules). --submodule=short short . . --submodule --submodule=log log . git-submodule(1) summary . --submodule=diff diff . diff . diff.submodule short . --color[=] diff . --color ( =) --color=always . always never auto . color.ui color.diff . --no-color diff. . --color=never . --color-moved[=] . diff.colorMoved . no zebra . : no () . default zebra . . plain color.diff.newMoved . color.diff.oldMoved diff . . blocks - . color.diff.(old|new)Moved . . zebra blocks . color.diff.(old|new)Moved color.diff.(old|new)MovedAlternative . . dimmed-zebra zebra (dim) . . dimmed_zebra . --no-color-moved . . --color-moved=no . --color-moved-ws=,... --color-moved . diff.colorMovedWS . : no . ignore-space-at-eol (EOL). ignore-space-change . . ignore-all-space . . allow-indentation-change . . --no-color-moved-ws . . --color-moved-ws=no . --word-diff[=] --word-diff-regex . plain : color . --color . plain [-removed-] {added}. . porcelain . // diff (unified diff) +/-/` ` . (newlines) ~ . none (word diff). . --word-diff diff (hunk) . diff word-diff . . --diff-algorithm . --word-diff-regex= . --word-diff . . (!). |[^[:space:]] . (newline) (!) . --word-diff-regex=. . (regex) diff gitattributes(5) git- config(1) . diff . diff . --color-words[=] --word-diff=color ( ) --word-diff-regex=. --no-renames . --rename-empty, --no-rename-empty blob . --check . core.whitespace . ( ) . . --exit-code . --ws-error-highlight= context old new diff. none default new all old,new,context . diff.wsErrorHighlight new . color.diff.whitespace . --full-index (patch) blob pre-image post-image "index" . --binary --full-index diff git-apply . --patch . --abbrev[=] diff-raw diff-tree . diff-patch --full-index --full-index blob --abbrev . --abbrev= . -B[][/], --break-rewrites[=[][/]] . : (context) -B ( ). -B/70% ( ). -M ( -M ) -B ( ). -B20% . -M[], --find-renames[=] . ( / ). -M90% / . % -M5 -M50% . -M05 -M5% . -M100% . . -C[], --find-copies[=] . --find-copies-harder. -M . --find-copies-harder -C changeset . . . -C . -D, --irreversible-delete preimage diff preimage /dev/null . patch git apply . ( ) . -B preimage / . -l -M -C / . ( ). N O(N^2) . / / . diff.renameLimit . 0 . --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]] (A) (C) (D) (M) (R) ( ...) (T) (U) (X) (B). ( ) . * ( ) . --diff-filter=ad . diff . . -S ( /). . ( struct) : preimage -S . . -G / . -S --pickaxe-regex -G diff : + return frotz(nitfol, two->ptr, 1, 0); ... - hit = frotz(nitfol, mf2.ptr, 1, 0); git log -G"frotz\(nitfol" git log -S"frotz\(nitfol" --pickaxe-regex ( ). --text textconv . pickaxe gitdiffcore(7) . --cached . --merge-base (merge base) HEAD . . -m (not checked out) . git diff-index . (RAW OUTPUT FORMAT) git-diff-index git-diff-tree git-diff-files git diff --raw . : git-diff-index . git-diff-index --cached . git-diff-tree [-r] [...] . git-diff-files [...] . git diff-files (unmerged) "unmerged" "in-place edit" . : in-place edit :100644 100644 bcd1234 0123456 M file0 copy-edit :100644 100644 abcd123 1234567 C68 file1 file2 rename-edit :100644 100644 abcd123 1234567 R86 file1 file3 create :000000 100644 0000000 1234567 A file4 delete :100644 000000 1234567 0000000 D file5 unmerged :000000 000000 0000000 0000000 U file6 : 1. (colon). 2. (mode) "src" 000000 "src" . 3. (space). 4. (mode) "dst" 000000 "dst" . 5. (space). 6. sha1 "src" 0{40} "src" . 7. (space). 8. sha1 "dst" 0{40} "dst" "dst" . 9. (space). 10. (status) "" (score). 11. tab NUL -z . 12. "src" 13. tab NUL -z C R . 14. "dst" C R . 15. LF NUL -z . : o A: o C: () o D: o M: (mode) o R: o T: ( ) o U: ( / ) o X: "" ( ) C R ( ). M ( ) . sha1 "dst" 0 . : :100644 100644 5be4a4a 0000000 M file.c -z "" core.quotePath (quote) ( git-config(1)). -z NUL . (DIFF FORMAT FOR MERGES) git-diff-tree git-diff-files git-diff --raw -c --cc (diff) (merge commits) . : 1. (parent) (:) 2. "src" sha1 "src" 3. () 4. "" (score) 5. () -c --cc ( ). --combined-all-paths . -c --cc --combined-all-paths: ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar.sh ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey.c --combined-all-paths -c --cc : ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c desc.c desc.c ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo.sh bar.sh bar.sh ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey.c fuey.c phooey.c combined diff ( ) . P- (GENERATING PATCH TEXT WITH -P) git-diff(1) git-log(1) git-show(1) git-diff- index(1) git-diff-tree(1) git-diff-files(1) -p . GIT_EXTERNAL_DIFF GIT_DIFF_OPTS ( git(1)) diff ( gitattributes(5)) . -p : 1. "git diff" : diff --git a/file1 b/file2 a/ b/ / . /dev/null a/ b/ . / file1 file2 / / . 2. : old mode new mode deleted file mode new file mode copy from copy to rename from rename to similarity index dissimilarity index index .. . a/ b/ . (similarity index) (dissimilarity index) . . . index blob . . 3. <<>> core.quotePath ( git-config(1)). 4. file1 file2 . . a b : diff --git a/a b/b rename from a rename to b diff --git a/b b/a rename from b rename to a 5. (Hunk headers) . "Defining a custom hunk-header" gitattributes(5) . (COMBINED DIFF FORMAT) (diff) -c --cc (combined diff) (merge) . git-diff(1) git-show(1) . --diff-merges . << >> : diff --combined describe.c index fabadb8,cc95eb0..4866510 --- a/describe.c +++ b/describe.c @@@ -98,20 -98,12 +98,20 @@@ return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; } - static void describe(char *arg) -static void describe(struct commit *cmit, int last_one) ++static void describe(char *arg, int last_one) { + unsigned char sha1[20]; + struct commit *cmit; struct commit_list *list; static int initialized = 0; struct commit_name *n; + if (get_sha1(arg, sha1) < 0) + usage(describe_usage); + cmit = lookup_commit_reference(sha1); + if (!cmit) + usage(describe_usage); + if (!initialized) { initialized = 1; for_each_ref(get_name); 1. "git diff" ( -c ): diff --combined file ( --cc ): diff --cc file 2. ( ): index ,.. mode ,.. new file mode deleted file mode , mode ,.. . ( ) . 3. from-file/to-file : --- a/file +++ b/file (unified) /dev/null . --combined-all-paths from-file/to-file N+1 from-file/to-file N : --- a/file --- a/file --- a/file +++ b/file . 4. (chunk) patch -p1 . (apply) . index : @@@ @@@ ( + ) @ (chunk) . (unified) A B - ( -- A B ) + ( -- A B ) " " ( -- ) file1 file2... X X fileN . fileN X . - N fileN . + N fileN ( ). ( - file1 file2 ++ file1 file2 ). file1 file2 ( + ). git diff-tree -c ( file1..fileN ). git diff-files -c ( file1 << >> file2 << >> ). (OTHER DIFF FORMATS) --summary . --stat diffstat(1) . -p . --stat . arch/i386/Makefile arch/x86/Makefile : arch/{i386 => x86}/Makefile | 4 +-- --numstat diffstat(1) . --numstat : 1 2 README 3 1 arch/{i386 => x86}/Makefile : 1. 2. (tab) 3. 4. (tab) 5. ( /) 6. (newline). -z : 1 2 README NUL 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL : 1. 2. (tab) 3. 4. (tab) 5. NUL ( / ) 6. (preimage) 7. NUL ( / ) 8. (postimage) ( / ) 9. NUL. NUL /. NUL NUL . (OPERATING MODES) ( --cached) (diff) stat << >> . . CACHED --cached : show me the differences between HEAD and the current index contents (the ones I'd write using 'git write-tree') . : git diff-index --cached HEAD : commit.c git-commit.c update-index . git diff-files . git diff-index : torvalds@ppc970:~/git> git diff-index --cached HEAD :100644 000000 4161aecc6700a2eb579e842af0b7f22b98443f74 0000000000000000000000000000000000000000 D commit.c :000000 100644 0000000000000000000000000000000000000000 4161aecc6700a2eb579e842af0b7f22b98443f74 A git-commit.c . git diff-index --cached git write-tree . . git diff-index --cached : << >>. NON-CACHED <> git write-tree + git diff-tree . . non-cached : show me the differences between HEAD and the currently checked out tree - index contents _and_ files that aren't up to date . git diff-tree -r . sha1 <<>> . kernel/sched.c git update-index - <<>> : torvalds@ppc970:~/v2.6/linux> git diff-index --abbrev HEAD :100644 100644 7476bb5ba 000000000 M kernel/sched.c kernel/sched.c . sha1 . git diff-index . kernel/sched.c touch . git update-index . << >> << (dirty) >> . << >> sha1 << >> sha1 . (SEE ALSO) git-diff(1), git-diff-files(1), git-diff-tree(1), gitdiffcore(7), git(1) (GIT) git(1) Git 2.55.0 2026-06-29 GIT-DIFF-INDEX(1)