GIT-DIFF(1) Git GIT-DIFF(1) (NAME) git-diff - (SYNOPSIS) git diff [] [] [--] [...] git diff [] --cached [--merge-base] [] [--] [...] git diff [] [--merge-base] [...] [--] [...] git diff [] ... [--] [...] git diff [] git diff [] --no-index [--] [...] (DESCRIPTION) blob . git diff [] [--] [...] ( ) . . git-add(1) () . git diff [] --no-index [--] [...] . --no-index . --exit-code . (pathspecs) . . diff . git diff [] --cached [--merge-base] [] [--] [...] () . HEAD . HEAD ( unborn) . --staged --cached . --merge-base (merge base) HEAD . git diff --cached --merge-base A git diff --cached $(git merge-base A HEAD). git diff [] [--merge-base] [--] [...] . HEAD . --merge-base (merge base) HEAD . git diff --merge-base A git diff $(git merge-base A HEAD). git diff [] [--merge-base] [--] [...] . --merge-base <<>> (before) . git diff --merge-base A B git diff $(git merge-base A B) B. git diff [] ... [--] [...] . . @ ^! . A git diff A A^@ git diff A^! git show A diff . git diff [] .. [--] [...] ( ..) . HEAD . git diff [] ... [--] [...] . git diff A...B git diff $(git merge-base A B) B. HEAD . --merge-base .. . AUTO_MERGE ort ( git-merge(1)). AUTO_MERGE ( ). << >> (SPECIFYING REVISIONS) gitrevisions(7) . diff (.. ...) << >> (SPECIFYING RANGES) gitrevisions(7) . git diff [] 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 diff (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) . --find-object= . -S . blob . -t git-log (trees) . --pickaxe-all -S -G changeset . --pickaxe-regex -S POSIX . -O . diff.orderFile (override) ( git-config(1) ). diff.orderFile -O/dev/null . glob . ( ) . . ( ) . : o . o ("#") () . ("\") . o . fnmatch(3) FNM_PATHNAME . "foo*bar" "fooasdfbar" "foo/bar/baz/asdf" "foobarx" . --skip-to=, --rotate-to= ( skip to) ( rotate to). git difftool . -R (swap) index . --relative[=], --no-relative . ( bare) . --no-relative diff.relative --relative . -a, --text . --ignore-cr-at-eol (carriage-return) . --ignore-space-at-eol (EOL) . -b, --ignore-space-change . . -w, --ignore-all-space . . --ignore-blank-lines . -I, --ignore-matching-lines= . . --inter-hunk-context= (context) (hunks) diff . diff.interHunkContext 0 . -W, --function-context (context) . git diff ( " (Defining a custom hunk-header)" gitattributes(5) ). --exit-code diff(1) . 1 0 . --quiet . --exit-code . diff diff.trustExitCode diff..trustExitCode GIT_EXTERNAL_DIFF_TRUST_EXIT_CODE false . --ext-diff diff . diff gitattributes(5) git-log(1) . --no-ext-diff diff . --textconv, --no-textconv ( ) . gitattributes(5) . textconv diff (apply) . textconv git-diff(1) git- log(1) git- format-patch(1) (plumbing) diff . --ignore-submodules[=(none|untracked|dirty|all)] diff . all . none HEAD (superproject) (modified) ignore git-config(1) gitmodules(5) . untracked (dirty) ( ). dirty ( 1.7.0 ). all . --src-prefix= "a/" . --dst-prefix= "b/" . --no-prefix . --default-prefix ("a/" "b/") . diff.noprefix, diff.srcPrefix, diff.dstPrefix diff.mnemonicPrefix ( git-config(1) ). --line-prefix= . --ita-invisible-in-index git add -N git diff git diff --cached . git diff git diff --cached . --ita-visible-in-index . . --max-depth= (pathspec) . -1 . (wildcards) pathspec . foo/bar/baz : o --max-depth=0 -- foo: foo o --max-depth=1 -- foo: foo/bar o --max-depth=1 -- foo/bar: foo/bar/baz o --max-depth=1 -- foo foo/bar: foo/bar/baz o --max-depth=2 -- foo: foo/bar/baz (pathspec) . --max-depth=0 foo . . diff (tree objects) . gitdiffcore(7) . -1, --base, -2, --ours, -3, --theirs o "" (stage #1) -1 --base o " " (stage #2) -2 --ours o " " (stage #3) -3 --theirs. (stages) (unmerged) . "3-Way Merge" git- read-tree(1) . -0 diff "Unmerged" . . ... diff ( diff ). (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 . (EXAMPLES) $ git diff (1) $ git diff --cached (2) $ git diff HEAD (3) $ git diff AUTO_MERGE (4) 1. . 2. git commit -a . 3. git commit -a . 4. . $ git diff test (1) $ git diff HEAD -- ./test (2) $ git diff HEAD^ HEAD (3) 1. <> . 2. <> <> . 3. . $ git diff topic master (1) $ git diff topic..master (2) $ git diff topic...master (3) 1. topic master. 2. . 3. master topic . diff $ git diff --diff-filter=MRC (1) $ git diff --name-status (2) $ git diff arch/i386 include/asm-i386 (3) 1. () . 2. diff. 3. diff . diff $ git diff --find-copies-harder -B -C (1) $ git diff -R (2) 1. () ( ). 2. diff . (CONFIGURATION) git-config(1) . : diff.autoRefreshIndex git diff (stat) . git update-index --refresh stat . true . (Porcelain) git diff diff git diff-files . diff.dirstat --dirstat --dirstat git diff . ( --dirstat=,..) . ( diff.dirstat ) changes,noncumulative,3 . : changes dirstat . . . . lines dirstat diff /. ( ). --dirstat changes . --*stat . files dirstat . dirstat . --dirstat . cumulative . cumulative . () noncumulative . ( ) . . : : files,10,cumulative. diff.statNameWidth --stat. --stat format-patch . diff.statGraphWidth --stat. --stat format-patch . diff.context diff . -U . diff.interHunkContext diff . --inter-hunk-context . diff.external diff diff . GIT_EXTERNAL_DIFF . <> git(1) . : diff gitattributes(5) . diff.trustExitCode true diff.external 0 1 diff(1). false ( ) 0 . (fatal) . diff.ignoreSubmodules --ignore-submodules . (Porcelain) git diff diff git diff-files. git checkout git switch . all status.submoduleSummary git commit git status --ignore-submodules . git submodule . untracked . diff.mnemonicPrefix git diff a/ b/ . diff : git diff (i) (w) git diff HEAD (c) (w) git diff --cached (c) (i) git diff HEAD: (o) (w) git diff --no-index . diff.noPrefix git diff . diff.srcPrefix git diff . a/ . diff.dstPrefix git diff . b/ . diff.relative true git diff . diff.orderFile diff . -O . diff.orderFile . diff.renameLimit / -l git diff . . . diff.renames . false . true . copies copy . true . (Porcelain) git diff git- diff(1) git-log(1) git-diff-files(1). diff.suppressBlankEmpty . false . diff.submodule . short . log git-submodule(1) summary . diff diff . short . diff.wordRegex (POSIX Extended Regular Expression) "" . "" . diff..command diff. gitattributes(5) . diff..trustExitCode true diff..command diff(1) . false . . diff..xfuncname diff . . gitattributes(5) . diff..binary true diff . gitattributes(5) . diff..textconv diff . diff . gitattributes(5) . diff..wordRegex diff . gitattributes(5) . diff..cachetextconv true diff . gitattributes(5) . diff.indentHeuristic false (heuristics) diff . diff.algorithm diff . : default, myers diff. . minimal diff . patience "patience diff" . histogram patience " " . diff.wsErrorHighlight context old new diff . none default new all old,new,context . color.diff.whitespace . --ws-error-highlight= . diff.colorMoved true diff . --color-moved . true . false . diff.colorMovedWS diff.colorMoved . --color-moved-ws git-diff(1) . (SEE ALSO) diff(1), git-difftool(1), git-log(1), gitdiffcore(7), git-format- patch(1), git-apply(1), git-show(1) (GIT) git(1) Git 2.55.0 2026-06-29 GIT-DIFF(1)