@@ -3,7 +3,7 @@ git-apply(1)
3
3
4
4
NAME
5
5
----
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
7
7
8
8
9
9
SYNOPSIS
@@ -20,8 +20,11 @@ SYNOPSIS
20
20
21
21
DESCRIPTION
22
22
-----------
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.
25
28
26
29
OPTIONS
27
30
-------
@@ -34,7 +37,7 @@ OPTIONS
34
37
input. Turns off "apply".
35
38
36
39
--numstat::
37
- Similar to \ --stat, but shows the number of added and
40
+ Similar to ` --stat` , but shows the number of added and
38
41
deleted lines in decimal notation and the pathname without
39
42
abbreviation, to make it more machine friendly. For
40
43
binary files, outputs two `-` instead of saying
@@ -48,22 +51,22 @@ OPTIONS
48
51
49
52
--check::
50
53
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
52
55
file and detects errors. Turns off "apply".
53
56
54
57
--index::
55
- When --check is in effect, or when applying the patch
58
+ When ` --check` is in effect, or when applying the patch
56
59
(which is the default when none of the options that
57
60
disables it is in effect), make sure the patch is
58
61
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
60
63
up-to-date, it is flagged as an error. This flag also
61
64
causes the index file to be updated.
62
65
63
66
--cached::
64
67
Apply a patch without touching the working tree. Instead take the
65
68
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` .
67
70
68
71
--build-fake-ancestor=<file>::
69
72
Newer 'git-diff' output has embedded 'index information'
@@ -87,11 +90,13 @@ the information is read from the current index instead.
87
90
rejected hunks in corresponding *.rej files.
88
91
89
92
-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.
95
100
96
101
-p<n>::
97
102
Remove <n> leading slashes from traditional diff paths. The
@@ -107,8 +112,8 @@ the information is read from the current index instead.
107
112
By default, 'git-apply' expects that the patch being
108
113
applied is a unified diff with at least one line of context.
109
114
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` .
112
117
+
113
118
Note, for the reasons stated above usage of context-free patches is
114
119
discouraged.
@@ -144,7 +149,7 @@ discouraged.
144
149
be useful when importing patchsets, where you want to include certain
145
150
files or directories.
146
151
+
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
148
153
order they appear on the command line, and the first match determines if a
149
154
patch to each path is used. A patch to a path that does not match any
150
155
include/exclude pattern is used by default if there is no include pattern
@@ -227,13 +232,13 @@ Submodules
227
232
If the patch contains any changes to submodules then 'git-apply'
228
233
treats these changes as follows.
229
234
230
- If --index is specified (explicitly or implicitly), then the submodule
235
+ If ` --index` is specified (explicitly or implicitly), then the submodule
231
236
commits must match the index exactly for the patch to apply. If any
232
237
of the submodules are checked-out, then these check-outs are completely
233
238
ignored, i.e., they are not required to be up-to-date or clean and they
234
239
are not updated.
235
240
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
237
242
are ignored and only the absence or presence of the corresponding
238
243
subdirectory is checked and (if possible) updated.
239
244
0 commit comments