Home Explore Blog CI



git

1st chunk of `Documentation/diff-options.adoc`
f36dac559e6b62d676184c9e3e7dde3905ed759a3bdcf5340000000100000fb6
// Please don't remove this comment as asciidoc behaves badly when
// the first non-empty line is ifdef/ifndef. The symptom is that
// without this comment the <git-diff-core> attribute conditionally
// defined below ends up being defined unconditionally.
// Last checked with asciidoc 7.0.2.

ifndef::git-format-patch[]
ifndef::git-diff[]
ifndef::git-log[]
:git-diff-core: 1
endif::git-log[]
endif::git-diff[]
endif::git-format-patch[]

ifdef::git-format-patch[]
-p::
--no-stat::
	Generate plain patches without any diffstats.
endif::git-format-patch[]

ifndef::git-format-patch[]
`-p`::
`-u`::
`--patch`::
	Generate patch (see <<generate_patch_text_with_p>>).
ifdef::git-diff[]
	This is the default.
endif::git-diff[]

`-s`::
`--no-patch`::
	Suppress all output from the diff machinery.  Useful for
	commands like `git show` that show the patch by default to
	squelch their output, or to cancel the effect of options like
	`--patch`, `--stat` earlier on the command line in an alias.

endif::git-format-patch[]

ifdef::git-log[]
-m::
	Show diffs for merge commits in the default format. This is
	similar to `--diff-merges=on`, except `-m` will
	produce no output unless `-p` is given as well.

-c::
	Produce combined diff output for merge commits.
	Shortcut for `--diff-merges=combined -p`.

--cc::
	Produce dense combined diff output for merge commits.
	Shortcut for `--diff-merges=dense-combined -p`.

--dd::
	Produce diff with respect to first parent for both merge and
	regular commits.
	Shortcut for `--diff-merges=first-parent -p`.

--remerge-diff::
	Produce remerge-diff output for merge commits.
	Shortcut for `--diff-merges=remerge -p`.

--no-diff-merges::
	Synonym for `--diff-merges=off`.

--diff-merges=<format>::
	Specify diff format to be used for merge commits. Default is
	{diff-merges-default} unless `--first-parent` is in use, in
	which case `first-parent` is the default.
+
The following formats are supported:
+
--
off, none::
	Disable output of diffs for merge commits. Useful to override
	implied value.

on, m::
	Make diff output for merge commits to be shown in the default
	format. The default format can be changed using
	`log.diffMerges` configuration variable, whose default value
	is `separate`.

first-parent, 1::
	Show full diff with respect to first parent. This is the same
	format as `--patch` produces for non-merge commits.

separate::
	Show full diff with respect to each of parents.
	Separate log entry and diff is generated for each parent.

combined, c::
	Show differences from each of the parents to the merge
	result simultaneously instead of showing pairwise diff between
	a parent and the result one at a time. Furthermore, it lists
	only files which were modified from all parents.

dense-combined, cc::
	Further compress output produced by `--diff-merges=combined`
	by omitting uninteresting hunks whose contents in the parents
	have only two variants and the merge result picks one of them
	without modification.

remerge, r::
	Remerge two-parent merge commits to create a temporary tree
	object--potentially containing files with conflict markers
	and such.  A diff is then shown between that temporary tree
	and the actual merge commit.
+
The output emitted when this option is used is subject to change, and
so is its interaction with other options (unless explicitly
documented).
--

--combined-all-paths::
	Cause combined diffs (used for merge commits) to
	list the name of the file from all parents.  It thus only has
	effect when `--diff-merges=[dense-]combined` is in use, and
	is likely only useful if filename changes are detected (i.e.
	when either rename or copy detection have been requested).
endif::git-log[]

`-U<n>`::
`--unified=<n>`::
	Generate diffs with _<n>_ lines of context instead of
	the usual three.
ifndef::git-format-patch[]
	Implies `--patch`.
endif::git-format-patch[]

`--output=<file>`::
	Output to a specific file instead of stdout.

`--output-indicator-new=<char>`::
`--output-indicator-old=<char>`::
`--output-indicator-context=<char>`::

Title: Git Diff Options
Summary
This section describes the various options available for generating diffs in Git, including options for formatting, filtering, and customizing the output of diff commands, such as generating patches, showing diffs for merge commits, and controlling the amount of context shown in the output, with various flags and parameters to refine the behavior of these commands.