Home Explore Blog CI



git

10th chunk of `Documentation/diff-options.adoc`
90dd38e7e222e8172e38d242b513c13f99c9d94a637f40340000000100000bad
 are ignored, so they can be used as separators for
   readability.

 - Lines starting with a hash ("`#`") are ignored, so they can be used
   for comments.  Add a backslash ("`\`") to the beginning of the
   pattern if it starts with a hash.

 - Each other line contains a single pattern.
--
+
Patterns have the same syntax and semantics as patterns used for
`fnmatch`(3) without the `FNM_PATHNAME` flag, except a pathname also
matches a pattern if removing any number of the final pathname
components matches the pattern.  For example, the pattern "`foo*bar`"
matches "`fooasdfbar`" and "`foo/bar/baz/asdf`" but not "`foobarx`".

`--skip-to=<file>`::
`--rotate-to=<file>`::
	Discard the files before the named _<file>_ from the output
	(i.e. 'skip to'), or move them to the end of the output
	(i.e. 'rotate to').  These options were invented primarily for the use
	of the `git difftool` command, and may not be very useful
	otherwise.

ifndef::git-format-patch[]
`-R`::
	Swap two inputs; that is, show differences from index or
	on-disk file to tree contents.
endif::git-format-patch[]

`--relative[=<path>]`::
`--no-relative`::
	When run from a subdirectory of the project, it can be
	told to exclude changes outside the directory and show
	pathnames relative to it with this option.  When you are
	not in a subdirectory (e.g. in a bare repository), you
	can name which subdirectory to make the output relative
	to by giving a _<path>_ as an argument.
	`--no-relative` can be used to countermand both `diff.relative` config
	option and previous `--relative`.

`-a`::
`--text`::
	Treat all files as text.

`--ignore-cr-at-eol`::
	Ignore carriage-return at the end of line when doing a comparison.

`--ignore-space-at-eol`::
	Ignore changes in whitespace at EOL.

`-b`::
`--ignore-space-change`::
	Ignore changes in amount of whitespace.  This ignores whitespace
	at line end, and considers all other sequences of one or
	more whitespace characters to be equivalent.

`-w`::
`--ignore-all-space`::
	Ignore whitespace when comparing lines.  This ignores
	differences even if one line has whitespace where the other
	line has none.

`--ignore-blank-lines`::
	Ignore changes whose lines are all blank.


`-I<regex>`::
`--ignore-matching-lines=<regex>`::
	Ignore changes whose all lines match _<regex>_.  This option may
	be specified more than once.

`--inter-hunk-context=<number>`::
	Show the context between diff hunks, up to the specified _<number>_
	of lines, thereby fusing hunks that are close to each other.
	Defaults to `diff.interHunkContext` or 0 if the config option
	is unset.

`-W`::
`--function-context`::
	Show whole function as context lines for each change.
	The function names are determined in the same way as
	`git diff` works out patch hunk headers (see "Defining a
	custom hunk-header" in linkgit:gitattributes[5]).

ifndef::git-format-patch[]
ifndef::git-log[]
`--exit-code`::
	Make the program exit with codes similar to `diff`(1).
	That is, it exits with 1 if there

Title: Git Diff Options for Ignoring, Filtering, and Formatting
Summary
This section describes various Git diff options for ignoring certain changes, filtering output, and customizing the format, including ignoring whitespace, blank lines, and specific patterns, as well as options for controlling context lines, function context, and exit codes, allowing users to tailor the diff output to their needs.