blob: d9137c74898f839a8ee5e79daf1080b2ec882dfd [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-apply(1)
2============
3
4NAME
5----
6git-apply - Apply patch on a git index file and a work tree
7
8
9SYNOPSIS
10--------
Junio C Hamano235a91e2006-01-07 01:13:5811[verse]
12'git-apply' [--stat] [--numstat] [--summary] [--check] [--index] [--apply]
Junio C Hamano6b2cee12006-08-26 08:43:3113 [--no-add] [--index-info] [--allow-binary-replacement | --binary]
14 [-R | --reverse] [--reject] [-z] [-pNUM] [-CNUM] [--inaccurate-eof]
15 [--whitespace=<nowarn|warn|error|error-all|strip>] [--exclude=PATH]
16 [--cached] [--verbose] [<patch>...]
Junio C Hamano1a4e8412005-12-27 08:17:2317
18DESCRIPTION
19-----------
20Reads supplied diff output and applies it on a git index file
21and a work tree.
22
23OPTIONS
24-------
25<patch>...::
26The files to read patch from. '-' can be used to read
27from the standard input.
28
29--stat::
30Instead of applying the patch, output diffstat for the
31input. Turns off "apply".
32
33--numstat::
34Similar to \--stat, but shows number of added and
35deleted lines in decimal notation and pathname without
36abbreviation, to make it more machine friendly. Turns
37off "apply".
38
39--summary::
40Instead of applying the patch, output a condensed
41summary of information obtained from git diff extended
42headers, such as creations, renames and mode changes.
43Turns off "apply".
44
45--check::
46Instead of applying the patch, see if the patch is
47applicable to the current work tree and/or the index
48file and detects errors. Turns off "apply".
49
50--index::
51When --check is in effect, or when applying the patch
52(which is the default when none of the options that
53disables it is in effect), make sure the patch is
54applicable to what the current index file records. If
55the file to be patched in the work tree is not
56up-to-date, it is flagged as an error. This flag also
57causes the index file to be updated.
58
Junio C Hamano6b2cee12006-08-26 08:43:3159--cached::
60Apply a patch without touching the working tree. Instead, take the
61cached data, apply the patch, and store the result in the index,
62without using the working tree. This implies '--index'.
63
Junio C Hamano1a4e8412005-12-27 08:17:2364--index-info::
65Newer git-diff output has embedded 'index information'
66for each blob to help identify the original version that
67the patch applies to. When this flag is given, and if
68the original version of the blob is available locally,
69outputs information about them to the standard output.
70
Junio C Hamano6b2cee12006-08-26 08:43:3171-R, --reverse::
72Apply the patch in reverse.
73
74--reject::
75For atomicity, gitlink:git-apply[1] by default fails the whole patch and
76does not touch the working tree when some of the hunks
77do not apply. This option makes it apply
Junio C Hamano9adfc6a2006-08-28 07:18:3878the parts of the patch that are applicable, and leave the
79rejected hunks in corresponding *.rej files.
Junio C Hamano6b2cee12006-08-26 08:43:3180
Junio C Hamano1a4e8412005-12-27 08:17:2381-z::
82When showing the index information, do not munge paths,
83but use NUL terminated machine readable format. Without
84this flag, the pathnames output will have TAB, LF, and
85backslash characters replaced with `\t`, `\n`, and `\\`,
86respectively.
87
Junio C Hamano8af15b02006-02-01 00:59:2688-p<n>::
89Remove <n> leading slashes from traditional diff paths. The
90default is 1.
91
Junio C Hamano54559c82006-04-13 07:45:1292-C<n>::
93Ensure at least <n> lines of surrounding context match before
94and after each change. When fewer lines of surrounding
Junio C Hamano33db4372006-06-07 19:51:4595context exist they all must match. By default no context is
Junio C Hamano54559c82006-04-13 07:45:1296ever ignored.
97
Junio C Hamano3eb513f2006-09-18 02:47:1698--unidiff-zero::
99By default, gitlink:git-apply[1] expects that the patch being
100applied is a unified diff with at least one line of context.
101This provides good safety measures, but breaks down when
102applying a diff generated with --unified=0. To bypass these
103checks use '--unidiff-zero'.
104+
105Note, for the reasons stated above usage of context-free patches are
106discouraged.
107
Junio C Hamano1a4e8412005-12-27 08:17:23108--apply::
Junio C Hamano6b2cee12006-08-26 08:43:31109If you use any of the options marked "Turns off
110'apply'" above, gitlink:git-apply[1] reads and outputs the
Junio C Hamano1a4e8412005-12-27 08:17:23111information you asked without actually applying the
112patch. Give this flag after those flags to also apply
113the patch.
114
115--no-add::
116When applying a patch, ignore additions made by the
117patch. This can be used to extract common part between
118two files by first running `diff` on them and applying
119the result with this option, which would apply the
120deletion part but not addition part.
121
Junio C Hamano6b2cee12006-08-26 08:43:31122--allow-binary-replacement, --binary::
Junio C Hamanofd73d892006-09-14 07:38:22123Historically we did not allow binary patch applied
124without an explicit permission from the user, and this
125flag was the way to do so. Currently we always allow binary
126patch application, so this is a no-op.
Junio C Hamano1a4e8412005-12-27 08:17:23127
Junio C Hamano6b2cee12006-08-26 08:43:31128--exclude=<path-pattern>::
129Don't apply changes to files matching the given path pattern. This can
130be useful when importing patchsets, where you want to exclude certain
131files or directories.
132
Junio C Hamano5f327762006-03-02 09:14:51133--whitespace=<option>::
134When applying a patch, detect a new or modified line
135that ends with trailing whitespaces (this includes a
136line that solely consists of whitespaces). By default,
137the command outputs warning messages and applies the
138patch.
Junio C Hamano6b2cee12006-08-26 08:43:31139When gitlink:git-apply[1] is used for statistics and not applying a
Junio C Hamano5f327762006-03-02 09:14:51140patch, it defaults to `nowarn`.
141You can use different `<option>` to control this
Junio C Hamano341071d2006-06-04 07:24:48142behavior:
Junio C Hamano5f327762006-03-02 09:14:51143+
144* `nowarn` turns off the trailing whitespace warning.
145* `warn` outputs warnings for a few such errors, but applies the
146 patch (default).
147* `error` outputs warnings for a few such errors, and refuses
148 to apply the patch.
149* `error-all` is similar to `error` but shows all errors.
150* `strip` outputs warnings for a few such errors, strips out the
151 trailing whitespaces and applies the patch.
152
Junio C Hamano6b2cee12006-08-26 08:43:31153--inacurate-eof::
154Under certain circumstances, some versions of diff do not correctly
155detect a missing new-line at the end of the file. As a result, patches
156created by such diff programs do not record incomplete lines
157correctly. This option adds support for applying such patches by
158working around this bug.
159
160--verbose::
161Report progress to stderr. By default, only a message about the
162current patch being applied will be printed. This option will cause
163additional information to be reported.
Junio C Hamano5f327762006-03-02 09:14:51164
165Configuration
166-------------
167
168apply.whitespace::
169When no `--whitespace` flag is given from the command
170line, this configuration item is used as the default.
171
172
Junio C Hamano1a4e8412005-12-27 08:17:23173Author
174------
175Written by Linus Torvalds <torvalds@osdl.org>
176
177Documentation
178--------------
179Documentation by Junio C Hamano
180
181GIT
182---
183Part of the gitlink:git[7] suite
184