blob: fb3f752ab9f5f06580ff84a06617b2d9a2dd28bf [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamano5f327762006-03-02 09:14:516<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-apply(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-apply(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-apply -
Junio C Hamano7c73c662007-01-19 00:37:50269 Apply a patch on a git index file and a working tree
Junio C Hamano1a4e8412005-12-27 08:17:23270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamano235a91e2006-01-07 01:13:58275<div class="verseblock">
Junio C Hamano0e3cb532007-04-17 08:28:11276<div class="content"><em>git-apply</em> [--stat] [--numstat] [--summary] [--check] [--index]
Junio C Hamano01d8f832007-09-24 07:37:30277 [--apply] [--no-add] [--build-fake-ancestor &lt;file&gt;] [-R | --reverse]
Junio C Hamano0e3cb532007-04-17 08:28:11278 [--allow-binary-replacement | --binary] [--reject] [-z]
279 [-pNUM] [-CNUM] [--inaccurate-eof] [--cached]
Junio C Hamano942b35e2007-12-09 10:19:33280 [--whitespace=&lt;nowarn|warn|fix|error|error-all&gt;]
Junio C Hamano0e3cb532007-04-17 08:28:11281 [--exclude=PATH] [--verbose] [&lt;patch&gt;&#8230;]</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23282</div>
283<h2>DESCRIPTION</h2>
284<div class="sectionbody">
285<p>Reads supplied diff output and applies it on a git index file
286and a work tree.</p>
287</div>
288<h2>OPTIONS</h2>
289<div class="sectionbody">
290<dl>
291<dt>
292&lt;patch&gt;&#8230;
293</dt>
294<dd>
295<p>
296 The files to read patch from. <em>-</em> can be used to read
297 from the standard input.
298</p>
299</dd>
300<dt>
301--stat
302</dt>
303<dd>
304<p>
305 Instead of applying the patch, output diffstat for the
306 input. Turns off "apply".
307</p>
308</dd>
309<dt>
310--numstat
311</dt>
312<dd>
313<p>
314 Similar to --stat, but shows number of added and
315 deleted lines in decimal notation and pathname without
Junio C Hamanod793de52006-12-26 09:11:43316 abbreviation, to make it more machine friendly. For
317 binary files, outputs two <tt>-</tt> instead of saying
318 <tt>0 0</tt>. Turns off "apply".
Junio C Hamano1a4e8412005-12-27 08:17:23319</p>
320</dd>
321<dt>
322--summary
323</dt>
324<dd>
325<p>
326 Instead of applying the patch, output a condensed
327 summary of information obtained from git diff extended
328 headers, such as creations, renames and mode changes.
329 Turns off "apply".
330</p>
331</dd>
332<dt>
333--check
334</dt>
335<dd>
336<p>
337 Instead of applying the patch, see if the patch is
338 applicable to the current work tree and/or the index
339 file and detects errors. Turns off "apply".
340</p>
341</dd>
342<dt>
343--index
344</dt>
345<dd>
346<p>
347 When --check is in effect, or when applying the patch
348 (which is the default when none of the options that
349 disables it is in effect), make sure the patch is
350 applicable to what the current index file records. If
351 the file to be patched in the work tree is not
352 up-to-date, it is flagged as an error. This flag also
353 causes the index file to be updated.
354</p>
355</dd>
356<dt>
Junio C Hamano6b2cee12006-08-26 08:43:31357--cached
358</dt>
359<dd>
360<p>
361 Apply a patch without touching the working tree. Instead, take the
362 cached data, apply the patch, and store the result in the index,
363 without using the working tree. This implies <em>--index</em>.
364</p>
365</dd>
366<dt>
Junio C Hamano01d8f832007-09-24 07:37:30367--build-fake-ancestor &lt;file&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23368</dt>
369<dd>
370<p>
371 Newer git-diff output has embedded <em>index information</em>
372 for each blob to help identify the original version that
373 the patch applies to. When this flag is given, and if
Junio C Hamano01d8f832007-09-24 07:37:30374 the original versions of the blobs is available locally,
375 builds a temporary index containing those blobs.
Junio C Hamano1a4e8412005-12-27 08:17:23376</p>
Junio C Hamano01d8f832007-09-24 07:37:30377<p>When a pure mode change is encountered (which has no index information),
378the information is read from the current index instead.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23379</dd>
380<dt>
Junio C Hamano6b2cee12006-08-26 08:43:31381-R, --reverse
382</dt>
383<dd>
384<p>
385 Apply the patch in reverse.
386</p>
387</dd>
388<dt>
389--reject
390</dt>
391<dd>
392<p>
393 For atomicity, <a href="git-apply.html">git-apply(1)</a> by default fails the whole patch and
394 does not touch the working tree when some of the hunks
395 do not apply. This option makes it apply
Junio C Hamano9adfc6a2006-08-28 07:18:38396 the parts of the patch that are applicable, and leave the
397 rejected hunks in corresponding *.rej files.
Junio C Hamano6b2cee12006-08-26 08:43:31398</p>
399</dd>
400<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23401-z
402</dt>
403<dd>
404<p>
405 When showing the index information, do not munge paths,
406 but use NUL terminated machine readable format. Without
407 this flag, the pathnames output will have TAB, LF, and
408 backslash characters replaced with <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
409 respectively.
410</p>
411</dd>
412<dt>
Junio C Hamano8af15b02006-02-01 00:59:26413-p&lt;n&gt;
414</dt>
415<dd>
416<p>
417 Remove &lt;n&gt; leading slashes from traditional diff paths. The
418 default is 1.
419</p>
420</dd>
421<dt>
Junio C Hamano54559c82006-04-13 07:45:12422-C&lt;n&gt;
423</dt>
424<dd>
425<p>
426 Ensure at least &lt;n&gt; lines of surrounding context match before
427 and after each change. When fewer lines of surrounding
Junio C Hamano33db4372006-06-07 19:51:45428 context exist they all must match. By default no context is
Junio C Hamano54559c82006-04-13 07:45:12429 ever ignored.
430</p>
431</dd>
432<dt>
Junio C Hamano3eb513f2006-09-18 02:47:16433--unidiff-zero
434</dt>
435<dd>
436<p>
437 By default, <a href="git-apply.html">git-apply(1)</a> expects that the patch being
438 applied is a unified diff with at least one line of context.
439 This provides good safety measures, but breaks down when
440 applying a diff generated with --unified=0. To bypass these
441 checks use <em>--unidiff-zero</em>.
442</p>
443<p>Note, for the reasons stated above usage of context-free patches are
444discouraged.</p>
445</dd>
446<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23447--apply
448</dt>
449<dd>
450<p>
Junio C Hamano6b2cee12006-08-26 08:43:31451 If you use any of the options marked "Turns off
452 <em>apply</em>" above, <a href="git-apply.html">git-apply(1)</a> reads and outputs the
Junio C Hamano1a4e8412005-12-27 08:17:23453 information you asked without actually applying the
454 patch. Give this flag after those flags to also apply
455 the patch.
456</p>
457</dd>
458<dt>
459--no-add
460</dt>
461<dd>
462<p>
463 When applying a patch, ignore additions made by the
Junio C Hamano3a702342007-12-12 21:34:02464 patch. This can be used to extract the common part between
Junio C Hamano1a4e8412005-12-27 08:17:23465 two files by first running <tt>diff</tt> on them and applying
466 the result with this option, which would apply the
467 deletion part but not addition part.
468</p>
469</dd>
470<dt>
Junio C Hamano6b2cee12006-08-26 08:43:31471--allow-binary-replacement, --binary
Junio C Hamano1a4e8412005-12-27 08:17:23472</dt>
473<dd>
474<p>
Junio C Hamanofd73d892006-09-14 07:38:22475 Historically we did not allow binary patch applied
476 without an explicit permission from the user, and this
477 flag was the way to do so. Currently we always allow binary
478 patch application, so this is a no-op.
Junio C Hamano1a4e8412005-12-27 08:17:23479</p>
480</dd>
Junio C Hamano5f327762006-03-02 09:14:51481<dt>
Junio C Hamano6b2cee12006-08-26 08:43:31482--exclude=&lt;path-pattern&gt;
483</dt>
484<dd>
485<p>
486 Don't apply changes to files matching the given path pattern. This can
487 be useful when importing patchsets, where you want to exclude certain
488 files or directories.
489</p>
490</dd>
491<dt>
Junio C Hamano942b35e2007-12-09 10:19:33492--whitespace=&lt;action&gt;
Junio C Hamano5f327762006-03-02 09:14:51493</dt>
494<dd>
495<p>
Junio C Hamano942b35e2007-12-09 10:19:33496 When applying a patch, detect a new or modified line that has
497 whitespace errors. What are considered whitespace errors is
498 controlled by <tt>core.whitespace</tt> configuration. By default,
499 trailing whitespaces (including lines that solely consist of
500 whitespaces) and a space character that is immediately followed
501 by a tab character inside the initial indent of the line are
502 considered whitespace errors.
Junio C Hamano5f327762006-03-02 09:14:51503</p>
Junio C Hamano942b35e2007-12-09 10:19:33504<p>By default, the command outputs warning messages but applies the patch.
505When <a href="git-apply.html">git-apply(1)</a> is used for statistics and not applying a
506patch, it defaults to <tt>nowarn</tt>.</p>
507<p>You can use different <tt>&lt;action&gt;</tt> to control this
508behavior:</p>
Junio C Hamano5f327762006-03-02 09:14:51509<ul>
510<li>
511<p>
512<tt>nowarn</tt> turns off the trailing whitespace warning.
513</p>
514</li>
515<li>
516<p>
517<tt>warn</tt> outputs warnings for a few such errors, but applies the
Junio C Hamano942b35e2007-12-09 10:19:33518 patch as-is (default).
519</p>
520</li>
521<li>
522<p>
523<tt>fix</tt> outputs warnings for a few such errors, and applies the
524 patch after fixing them (<tt>strip</tt> is a synonym --- the tool
525 used to consider only trailing whitespaces as errors, and the
526 fix involved <em>stripping</em> them, but modern gits do more).
Junio C Hamano5f327762006-03-02 09:14:51527</p>
528</li>
529<li>
530<p>
531<tt>error</tt> outputs warnings for a few such errors, and refuses
532 to apply the patch.
533</p>
534</li>
535<li>
536<p>
537<tt>error-all</tt> is similar to <tt>error</tt> but shows all errors.
538</p>
539</li>
Junio C Hamano5f327762006-03-02 09:14:51540</ul>
541</dd>
Junio C Hamano6b2cee12006-08-26 08:43:31542<dt>
Junio C Hamano3a971022006-11-18 22:17:58543--inaccurate-eof
Junio C Hamano6b2cee12006-08-26 08:43:31544</dt>
545<dd>
546<p>
547 Under certain circumstances, some versions of diff do not correctly
548 detect a missing new-line at the end of the file. As a result, patches
549 created by such diff programs do not record incomplete lines
550 correctly. This option adds support for applying such patches by
551 working around this bug.
552</p>
553</dd>
554<dt>
Junio C Hamano0e3cb532007-04-17 08:28:11555-v, --verbose
Junio C Hamano6b2cee12006-08-26 08:43:31556</dt>
557<dd>
558<p>
559 Report progress to stderr. By default, only a message about the
560 current patch being applied will be printed. This option will cause
561 additional information to be reported.
562</p>
563</dd>
Junio C Hamano5f327762006-03-02 09:14:51564</dl>
565</div>
566<h2>Configuration</h2>
567<div class="sectionbody">
568<dl>
569<dt>
570apply.whitespace
571</dt>
572<dd>
573<p>
574 When no <tt>--whitespace</tt> flag is given from the command
575 line, this configuration item is used as the default.
576</p>
577</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23578</dl>
579</div>
Junio C Hamano3b178be2007-08-16 04:59:27580<h2>Submodules</h2>
581<div class="sectionbody">
582<p>If the patch contains any changes to submodules then <a href="git-apply.html">git-apply(1)</a>
583treats these changes as follows.</p>
584<p>If --index is specified (explicitly or implicitly), then the submodule
585commits must match the index exactly for the patch to apply. If any
586of the submodules are checked-out, then these check-outs are completely
587ignored, i.e., they are not required to be up-to-date or clean and they
588are not updated.</p>
589<p>If --index is not specified, then the submodule commits in the patch
590are ignored and only the absence of presence of the corresponding
591subdirectory is checked and (if possible) updated.</p>
592</div>
Junio C Hamano1a4e8412005-12-27 08:17:23593<h2>Author</h2>
594<div class="sectionbody">
595<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
596</div>
597<h2>Documentation</h2>
598<div class="sectionbody">
599<p>Documentation by Junio C Hamano</p>
600</div>
601<h2>GIT</h2>
602<div class="sectionbody">
603<p>Part of the <a href="git.html">git(7)</a> suite</p>
604</div>
605<div id="footer">
606<div id="footer-text">
Junio C Hamano35738e82008-01-07 07:55:46607Last updated 07-Jan-2008 07:50:01 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23608</div>
609</div>
610</body>
611</html>