Git Diff

Download git eBook


  • git diff [options] [<commit>] [--] [<path>…​]
  • git diff [options] --cached [<commit>] [--] [<path>…​]
  • git diff [options] <commit> <commit> [--] [<path>…​]
  • git diff [options] <blob> <blob>
  • git diff [options] [--no-index] [--] <path> <path>


-p, -u, --patchGenerate patch
-s, --no-patchSuppress diff output. Useful for commands like git show that show the patch by default, or to cancel the effect of --patch
--rawGenerate the diff in raw format
--diff-algorithm=Choose a diff algorithm. The variants are as follows: myers, minimal, patience, histogram
--summaryOutput a condensed summary of extended header information such as creations, renames and mode changes
--name-onlyShow only names of changed files
--name-statusShow names and statuses of changed files The most common statuses are M (Modified), A (Added), and D (Deleted)
--checkWarn if changes introduce conflict markers or whitespace errors. What are considered whitespace errors is controlled by core.whitespace configuration. By default, trailing whitespaces (including lines that solely consist of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors. Exits with non-zero status if problems are found. Not compatible with --exit-code
--full-indexInstead of the first handful of characters, show the full pre- and post-image blob object names on the "index" line when generating patch format output
--binaryIn addition to --full-index, output a binary diff that can be applied with git apply
-a, --textTreat all files as text.
--colorSet the color mode; i.e. use --color=always if you would like to pipe a diff to less and keep git's coloring

Related Examples


694 Contributors: 29
Tuesday, March 7, 2017
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial:

Download eBook