@@ -3,7 +3,7 @@ git-apply(1)
33
44NAME
55----
6- git-apply - Apply a patch on a git index file and/or a working tree
6+ git-apply - Apply a patch to files and/or to the index
77
88
99SYNOPSIS
@@ -20,8 +20,11 @@ SYNOPSIS
2020
2121DESCRIPTION
2222-----------
23- Reads supplied 'diff' output and applies it on a git index file
24- and a work tree.
23+ Reads the supplied diff output (i.e. "a patch") and applies it to files.
24+ With the `--index` option the patch is also applied to the index, and
25+ with the `--cache` option the patch is only applied to the index.
26+ Without these options, the command applies the patch only to files,
27+ and does not require them to be in a git repository.
2528
2629OPTIONS
2730-------
@@ -34,7 +37,7 @@ OPTIONS
3437 input. Turns off "apply".
3538
3639--numstat::
37- Similar to \ --stat, but shows the number of added and
40+ Similar to ` --stat` , but shows the number of added and
3841 deleted lines in decimal notation and the pathname without
3942 abbreviation, to make it more machine friendly. For
4043 binary files, outputs two `-` instead of saying
@@ -48,22 +51,22 @@ OPTIONS
4851
4952--check::
5053 Instead of applying the patch, see if the patch is
51- applicable to the current work tree and/or the index
54+ applicable to the current working tree and/or the index
5255 file and detects errors. Turns off "apply".
5356
5457--index::
55- When --check is in effect, or when applying the patch
58+ When ` --check` is in effect, or when applying the patch
5659 (which is the default when none of the options that
5760 disables it is in effect), make sure the patch is
5861 applicable to what the current index file records. If
59- the file to be patched in the work tree is not
62+ the file to be patched in the working tree is not
6063 up-to-date, it is flagged as an error. This flag also
6164 causes the index file to be updated.
6265
6366--cached::
6467 Apply a patch without touching the working tree. Instead take the
6568 cached data, apply the patch, and store the result in the index
66- without using the working tree. This implies ' --index' .
69+ without using the working tree. This implies ` --index` .
6770
6871--build-fake-ancestor=<file>::
6972 Newer 'git-diff' output has embedded 'index information'
@@ -87,11 +90,13 @@ the information is read from the current index instead.
8790 rejected hunks in corresponding *.rej files.
8891
8992-z::
90- When showing the index information, do not munge paths,
91- but use NUL terminated machine readable format. Without
92- this flag, the pathnames output will have TAB, LF, and
93- backslash characters replaced with `\t`, `\n`, and `\\`,
94- respectively.
93+ When `--numstat` has been given, do not munge pathnames,
94+ but use a NUL-terminated machine-readable format.
95+ +
96+ Without this option, each pathname output will have TAB, LF, double quotes,
97+ and backslash characters replaced with `\t`, `\n`, `\"`, and `\\`,
98+ respectively, and the pathname will be enclosed in double quotes if
99+ any of those replacements occurred.
95100
96101-p<n>::
97102 Remove <n> leading slashes from traditional diff paths. The
@@ -107,8 +112,8 @@ the information is read from the current index instead.
107112 By default, 'git-apply' expects that the patch being
108113 applied is a unified diff with at least one line of context.
109114 This provides good safety measures, but breaks down when
110- applying a diff generated with --unified=0. To bypass these
111- checks use ' --unidiff-zero' .
115+ applying a diff generated with ` --unified=0` . To bypass these
116+ checks use ` --unidiff-zero` .
112117+
113118Note, for the reasons stated above usage of context-free patches is
114119discouraged.
@@ -144,7 +149,7 @@ discouraged.
144149 be useful when importing patchsets, where you want to include certain
145150 files or directories.
146151+
147- When --exclude and --include patterns are used, they are examined in the
152+ When ` --exclude` and ` --include` patterns are used, they are examined in the
148153order they appear on the command line, and the first match determines if a
149154patch to each path is used. A patch to a path that does not match any
150155include/exclude pattern is used by default if there is no include pattern
@@ -227,13 +232,13 @@ Submodules
227232If the patch contains any changes to submodules then 'git-apply'
228233treats these changes as follows.
229234
230- If --index is specified (explicitly or implicitly), then the submodule
235+ If ` --index` is specified (explicitly or implicitly), then the submodule
231236commits must match the index exactly for the patch to apply. If any
232237of the submodules are checked-out, then these check-outs are completely
233238ignored, i.e., they are not required to be up-to-date or clean and they
234239are not updated.
235240
236- If --index is not specified, then the submodule commits in the patch
241+ If ` --index` is not specified, then the submodule commits in the patch
237242are ignored and only the absence or presence of the corresponding
238243subdirectory is checked and (if possible) updated.
239244
0 commit comments