1GIT-APPLY(1)                      Git Manual                      GIT-APPLY(1)
2
3
4

NAME

6       git-apply - Apply a patch on a git index file and a working tree
7

SYNOPSIS

9           git-apply [--stat] [--numstat] [--summary] [--check] [--index]
10                     [--apply] [--no-add] [--build-fake-ancestor <file>] [-R | --reverse]
11                     [--allow-binary-replacement | --binary] [--reject] [-z]
12                     [-pNUM] [-CNUM] [--inaccurate-eof] [--cached]
13                     [--whitespace=<nowarn|warn|error|error-all|strip>]
14                     [--exclude=PATH] [--verbose] [<patch>...]
15

DESCRIPTION

17       Reads supplied diff output and applies it on a git index file and a
18       work tree.
19

OPTIONS

21       <patch>...
22           The files to read patch from. - can be used to read from the
23           standard input.
24
25       --stat
26           Instead of applying the patch, output diffstat for the input. Turns
27           off "apply".
28
29       --numstat
30           Similar to --stat, but shows number of added and deleted lines in
31           decimal notation and pathname without abbreviation, to make it more
32           machine friendly. For binary files, outputs two - instead of saying
33           0 0. Turns off "apply".
34
35       --summary
36           Instead of applying the patch, output a condensed summary of
37           information obtained from git diff extended headers, such as
38           creations, renames and mode changes. Turns off "apply".
39
40       --check
41           Instead of applying the patch, see if the patch is applicable to
42           the current work tree and/or the index file and detects errors.
43           Turns off "apply".
44
45       --index
46           When --check is in effect, or when applying the patch (which is the
47           default when none of the options that disables it is in effect),
48           make sure the patch is applicable to what the current index file
49           records. If the file to be patched in the work tree is not
50           up-to-date, it is flagged as an error. This flag also causes the
51           index file to be updated.
52
53       --cached
54           Apply a patch without touching the working tree. Instead, take the
55           cached data, apply the patch, and store the result in the index,
56           without using the working tree. This implies --index.
57
58       --build-fake-ancestor <file>
59           Newer git-diff output has embedded index information for each blob
60           to help identify the original version that the patch applies to.
61           When this flag is given, and if the original versions of the blobs
62           is available locally, builds a temporary index containing those
63           blobs.
64
65           When a pure mode change is encountered (which has no index
66           information), the information is read from the current index
67           instead.
68
69       -R, --reverse
70           Apply the patch in reverse.
71
72       --reject
73           For atomicity, git-apply(1) by default fails the whole patch and
74           does not touch the working tree when some of the hunks do not
75           apply. This option makes it apply the parts of the patch that are
76           applicable, and leave the rejected hunks in corresponding *.rej
77           files.
78
79       -z
80           When showing the index information, do not munge paths, but use NUL
81           terminated machine readable format. Without this flag, the
82           pathnames output will have TAB, LF, and backslash characters
83           replaced with \t, \n, and \\, respectively.
84
85       -p<n>
86           Remove <n> leading slashes from traditional diff paths. The default
87           is 1.
88
89       -C<n>
90           Ensure at least <n> lines of surrounding context match before and
91           after each change. When fewer lines of surrounding context exist
92           they all must match. By default no context is ever ignored.
93
94       --unidiff-zero
95           By default, git-apply(1) expects that the patch being applied is a
96           unified diff with at least one line of context. This provides good
97           safety measures, but breaks down when applying a diff generated
98           with --unified=0. To bypass these checks use --unidiff-zero.
99
100           Note, for the reasons stated above usage of context-free patches
101           are discouraged.
102
103       --apply
104           If you use any of the options marked "Turns off apply" above, git-
105           apply(1) reads and outputs the information you asked without
106           actually applying the patch. Give this flag after those flags to
107           also apply the patch.
108
109       --no-add
110           When applying a patch, ignore additions made by the patch. This can
111           be used to extract common part between two files by first running
112           diff on them and applying the result with this option, which would
113           apply the deletion part but not addition part.
114
115       --allow-binary-replacement, --binary
116           Historically we did not allow binary patch applied without an
117           explicit permission from the user, and this flag was the way to do
118           so. Currently we always allow binary patch application, so this is
119           a no-op.
120
121       --exclude=<path-pattern>
122           Don´t apply changes to files matching the given path pattern. This
123           can be useful when importing patchsets, where you want to exclude
124           certain files or directories.
125
126       --whitespace=<option>
127           When applying a patch, detect a new or modified line that ends with
128           trailing whitespaces (this includes a line that solely consists of
129           whitespaces). By default, the command outputs warning messages and
130           applies the patch. When git-apply(1) is used for statistics and not
131           applying a patch, it defaults to nowarn. You can use different
132           <option> to control this behavior:
133
134
135           ·   nowarn turns off the trailing whitespace warning.
136
137           ·   warn outputs warnings for a few such errors, but applies the
138               patch (default).
139
140           ·   error outputs warnings for a few such errors, and refuses to
141               apply the patch.
142
143           ·   error-all is similar to error but shows all errors.
144
145           ·   strip outputs warnings for a few such errors, strips out the
146               trailing whitespaces and applies the patch.
147
148       --inaccurate-eof
149           Under certain circumstances, some versions of diff do not correctly
150           detect a missing new-line at the end of the file. As a result,
151           patches created by such diff programs do not record incomplete
152           lines correctly. This option adds support for applying such patches
153           by working around this bug.
154
155       -v, --verbose
156           Report progress to stderr. By default, only a message about the
157           current patch being applied will be printed. This option will cause
158           additional information to be reported.
159

CONFIGURATION

161       apply.whitespace
162           When no --whitespace flag is given from the command line, this
163           configuration item is used as the default.
164

SUBMODULES

166       If the patch contains any changes to submodules then git-apply(1)
167       treats these changes as follows.
168
169       If --index is specified (explicitly or implicitly), then the submodule
170       commits must match the index exactly for the patch to apply. If any of
171       the submodules are checked-out, then these check-outs are completely
172       ignored, i.e., they are not required to be up-to-date or clean and they
173       are not updated.
174
175       If --index is not specified, then the submodule commits in the patch
176       are ignored and only the absence of presence of the corresponding
177       subdirectory is checked and (if possible) updated.
178

AUTHOR

180       Written by Linus Torvalds <torvalds@osdl.org>
181

DOCUMENTATION

183       Documentation by Junio C Hamano
184

GIT

186       Part of the git(7) suite
187
188
189
190
191Git 1.5.3.3                       10/09/2007                      GIT-APPLY(1)
Impressum