Home Explore Blog CI



git

9th chunk of `Documentation/diff-options.adoc`
b269b3364b8080f53bf5bc3ba12c0cdbb3deec41339d93970000000100000fa4
 other criteria, nothing is selected.
+
Also, these upper-case letters can be downcased to exclude.  E.g.
`--diff-filter=ad` excludes added and deleted paths.
+
Note that not all diffs can feature all types. For instance, copied and
renamed entries cannot appear if detection for those types is disabled.

`-S<string>`::
	Look for differences that change the number of occurrences of
	the specified _<string>_ (i.e. addition/deletion) in a file.
	Intended for the scripter's use.
+
It is useful when you're looking for an exact block of code (like a
struct), and want to know the history of that block since it first
came into being: use the feature iteratively to feed the interesting
block in the preimage back into `-S`, and keep going until you get the
very first version of the block.
+
Binary files are searched as well.

`-G<regex>`::
	Look for differences whose patch text contains added/removed
	lines that match _<regex>_.
+
To illustrate the difference between `-S<regex>` `--pickaxe-regex` and
`-G<regex>`, consider a commit with the following diff in the same
file:
+
----
+    return frotz(nitfol, two->ptr, 1, 0);
...
-    hit = frotz(nitfol, mf2.ptr, 1, 0);
----
+
While `git log -G"frotz\(nitfol"` will show this commit, `git log
-S"frotz\(nitfol" --pickaxe-regex` will not (because the number of
occurrences of that string did not change).
+
Unless `--text` is supplied patches of binary files without a textconv
filter will be ignored.
+
See the 'pickaxe' entry in linkgit:gitdiffcore[7] for more
information.

`--find-object=<object-id>`::
	Look for differences that change the number of occurrences of
	the specified object. Similar to `-S`, just the argument is different
	in that it doesn't search for a specific string but for a specific
	object id.
+
The object can be a blob or a submodule commit. It implies the `-t` option in
`git-log` to also find trees.

`--pickaxe-all`::
	When `-S` or `-G` finds a change, show all the changes in that
	changeset, not just the files that contain the change
	in _<string>_.

`--pickaxe-regex`::
	Treat the _<string>_ given to `-S` as an extended POSIX regular
	expression to match.

endif::git-format-patch[]

`-O<orderfile>`::
	Control the order in which files appear in the output.
	This overrides the `diff.orderFile` configuration variable
	(see linkgit:git-config[1]).  To cancel `diff.orderFile`,
	use `-O/dev/null`.
+
The output order is determined by the order of glob patterns in
_<orderfile>_.
All files with pathnames that match the first pattern are output
first, all files with pathnames that match the second pattern (but not
the first) are output next, and so on.
All files with pathnames that do not match any pattern are output
last, as if there was an implicit match-all pattern at the end of the
file.
If multiple pathnames have the same rank (they match the same pattern
but no earlier patterns), their output order relative to each other is
the normal order.
+
_<orderfile>_ is parsed as follows:
+
--
 - Blank lines 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

Title: Git Diff Options for Searching, Filtering, and Ordering
Summary
This section describes various Git diff options for searching, filtering, and ordering changes, including searching for specific strings or regular expressions with `-S` and `-G`, finding objects with `--find-object`, controlling output order with `-O`, and skipping or rotating files with `--skip-to` and `--rotate-to`, allowing users to customize and refine their diff output.