Home Explore Blog CI



git

2nd chunk of `Documentation/git-diff.adoc`
2b95e5f9333cd800be4705487f0094ff48455587a4dcb2a90000000100000a3a
 results of a merge commit.  The first
	listed _<commit>_ must be the merge itself; the remaining two or
	more commits should be its parents.  Convenient ways to produce
	the desired set of revisions are to use the suffixes `@` and
	`^!`.  If `A` is a merge commit, then `git diff A A^@`,
	`git diff A^!` and `git show A` all give the same combined diff.

`git diff [<options>] <commit>..<commit> [--] [<path>...]`::

	This is synonymous to the earlier form (without the `..`) for
	viewing the changes between two arbitrary _<commit>_.  If _<commit>_ on
	one side is omitted, it will have the same effect as
	using `HEAD` instead.

`git diff [<options>] <commit>...<commit> [--] [<path>...]`::

	This form is to view the changes on the branch containing
	and up to the second _<commit>_, starting at a common ancestor
	of both _<commit>_.  `git diff A...B` is equivalent to
	`git diff $(git merge-base A B) B`.  You can omit any one
	of _<commit>_, which has the same effect as using `HEAD` instead.

Just in case you are doing something exotic, it should be
noted that all of the _<commit>_ in the above description, except
in the `--merge-base` case and in the last two forms that use `..`
notations, can be any _<tree>_. A tree of interest is the one pointed to
by the ref named `AUTO_MERGE`, which is written by the `ort` merge
strategy upon hitting merge conflicts (see linkgit:git-merge[1]).
Comparing the working tree with `AUTO_MERGE` shows changes you've made
so far to resolve textual conflicts (see the examples below).

For a more complete list of ways to spell _<commit>_, see
"SPECIFYING REVISIONS" section in linkgit:gitrevisions[7].
However, `diff` is about comparing two _endpoints_, not ranges,
and the range notations (`<commit>..<commit>` and `<commit>...<commit>`)
do not mean a range as defined in the
"SPECIFYING RANGES" section in linkgit:gitrevisions[7].

`git diff [<options>] <blob> <blob>`::

	This form is to view the differences between the raw
	contents of two blob objects.

OPTIONS
-------
:git-diff: 1
include::diff-options.adoc[]

`-1`::
`--base`::
`-2`::
`--ours`::
`-3`::
`--theirs`::
	Compare the working tree with
+
--
 * the "base" version (stage #1) when using `-1` or `--base`,
 * "our branch" (stage #2) when using `-2` or `--ours`, or
 * "their branch" (stage #3) when using `-3` or `--theirs`.
--
+
The index contains these stages only for unmerged entries i.e.
while resolving conflicts.  See linkgit:git-read-tree[1]
section "3-Way Merge" for detailed information.

`-0`::
	Omit diff output for unmerged entries and just show
	"Unmerged".  Can be used only when comparing

Title: Git Diff Command Options and Syntax
Summary
The git diff command provides various options and syntax to compare changes between commits, trees, and files, including comparing merge commits, viewing changes on a branch, and comparing raw contents of blob objects, with options to specify revisions, compare stages, and omit diff output for unmerged entries.