Autogenerated HTML docs for v1.6.6.1-383-g5a9f
[git/jnareb-git.git] / git-apply.html
blobb09a77f55ed901cee419aa2a181b8e454ce9eff3
1 <!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" />
6 <meta name="generator" content="AsciiDoc 8.2.5" />
7 <style type="text/css">
8 /* Debug borders */
9 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
11 border: 1px solid red;
15 body {
16 margin: 1em 5% 1em 5%;
19 a {
20 color: blue;
21 text-decoration: underline;
23 a:visited {
24 color: fuchsia;
27 em {
28 font-style: italic;
31 strong {
32 font-weight: bold;
35 tt {
36 color: navy;
39 h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
47 h1, h2, h3 {
48 border-bottom: 2px solid silver;
50 h2 {
51 padding-top: 0.5em;
53 h3 {
54 float: left;
56 h3 + * {
57 clear: left;
60 div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
65 hr {
66 border: 1px solid silver;
69 p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
74 pre {
75 padding: 0;
76 margin: 0;
79 span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
83 font-size: 1.1em;
85 span#email {
87 span#revision {
88 font-family: sans-serif;
91 div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
98 div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
102 div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
107 div#preamble,
108 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110 div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
115 div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
120 div.content { /* Block element content. */
121 padding: 0;
124 /* Block element titles. */
125 div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
132 div.title + * {
133 margin-top: 0;
136 td div.title:first-child {
137 margin-top: 0.0em;
139 div.content div.title:first-child {
140 margin-top: 0.0em;
142 div.content + div.title {
143 margin-top: 0.0em;
146 div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
152 div.listingblock {
153 margin-right: 0%;
155 div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
161 div.quoteblock > div.content {
162 padding-left: 2.0em;
165 div.attribution {
166 text-align: right;
168 div.verseblock + div.attribution {
169 text-align: left;
172 div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
180 div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
185 div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
190 div.verseblock div.content {
191 white-space: pre;
194 div.imageblock div.content { padding-left: 0; }
195 div.imageblock img { border: 1px solid silver; }
196 span.image img { border-style: none; }
198 dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
202 dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
207 dd > *:first-child {
208 margin-top: 0;
211 ul, ol {
212 list-style-position: outside;
214 div.olist2 ol {
215 list-style-type: lower-alpha;
218 div.tableblock > table {
219 border: 3px solid #527bbd;
221 thead {
222 font-family: sans-serif;
223 font-weight: bold;
225 tfoot {
226 font-weight: bold;
229 div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
233 div.hlist td {
234 padding-bottom: 5px;
236 td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
241 td.hlist2 {
242 vertical-align: top;
245 @media print {
246 div#footer-badges { display: none; }
249 div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
258 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
262 div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
266 div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
270 div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
274 include1::./stylesheets/xhtml11-manpage.css[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
282 div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
289 div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
295 div.quoteblock-content {
296 padding-left: 2.0em;
299 div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc a:visited { color: blue; }
306 </style>
307 <title>git-apply(1)</title>
308 </head>
309 <body>
310 <div id="header">
311 <h1>
312 git-apply(1) Manual Page
313 </h1>
314 <h2>NAME</h2>
315 <div class="sectionbody">
316 <p>git-apply -
317 Apply a patch to files and/or to the index
318 </p>
319 </div>
320 </div>
321 <h2>SYNOPSIS</h2>
322 <div class="sectionbody">
323 <div class="verseblock">
324 <div class="content"><em>git apply</em> [--stat] [--numstat] [--summary] [--check] [--index]
325 [--apply] [--no-add] [--build-fake-ancestor=&lt;file&gt;] [-R | --reverse]
326 [--allow-binary-replacement | --binary] [--reject] [-z]
327 [-pNUM] [-CNUM] [--inaccurate-eof] [--recount] [--cached]
328 [--ignore-space-change | --ignore-whitespace ]
329 [--whitespace=&lt;nowarn|warn|fix|error|error-all&gt;]
330 [--exclude=PATH] [--include=PATH] [--directory=&lt;root&gt;]
331 [--verbose] [&lt;patch&gt;&#8230;]</div></div>
332 </div>
333 <h2 id="_description">DESCRIPTION</h2>
334 <div class="sectionbody">
335 <div class="para"><p>Reads the supplied diff output (i.e. "a patch") and applies it to files.
336 With the <tt>--index</tt> option the patch is also applied to the index, and
337 with the <tt>--cache</tt> option the patch is only applied to the index.
338 Without these options, the command applies the patch only to files,
339 and does not require them to be in a git repository.</p></div>
340 </div>
341 <h2 id="_options">OPTIONS</h2>
342 <div class="sectionbody">
343 <div class="vlist"><dl>
344 <dt>
345 &lt;patch&gt;&#8230;
346 </dt>
347 <dd>
349 The files to read the patch from. <em>-</em> can be used to read
350 from the standard input.
351 </p>
352 </dd>
353 <dt>
354 --stat
355 </dt>
356 <dd>
358 Instead of applying the patch, output diffstat for the
359 input. Turns off "apply".
360 </p>
361 </dd>
362 <dt>
363 --numstat
364 </dt>
365 <dd>
367 Similar to <tt>--stat</tt>, but shows the number of added and
368 deleted lines in decimal notation and the pathname without
369 abbreviation, to make it more machine friendly. For
370 binary files, outputs two <tt>-</tt> instead of saying
371 <tt>0 0</tt>. Turns off "apply".
372 </p>
373 </dd>
374 <dt>
375 --summary
376 </dt>
377 <dd>
379 Instead of applying the patch, output a condensed
380 summary of information obtained from git diff extended
381 headers, such as creations, renames and mode changes.
382 Turns off "apply".
383 </p>
384 </dd>
385 <dt>
386 --check
387 </dt>
388 <dd>
390 Instead of applying the patch, see if the patch is
391 applicable to the current working tree and/or the index
392 file and detects errors. Turns off "apply".
393 </p>
394 </dd>
395 <dt>
396 --index
397 </dt>
398 <dd>
400 When <tt>--check</tt> is in effect, or when applying the patch
401 (which is the default when none of the options that
402 disables it is in effect), make sure the patch is
403 applicable to what the current index file records. If
404 the file to be patched in the working tree is not
405 up-to-date, it is flagged as an error. This flag also
406 causes the index file to be updated.
407 </p>
408 </dd>
409 <dt>
410 --cached
411 </dt>
412 <dd>
414 Apply a patch without touching the working tree. Instead take the
415 cached data, apply the patch, and store the result in the index
416 without using the working tree. This implies <tt>--index</tt>.
417 </p>
418 </dd>
419 <dt>
420 --build-fake-ancestor=&lt;file&gt;
421 </dt>
422 <dd>
424 Newer <em>git diff</em> output has embedded <em>index information</em>
425 for each blob to help identify the original version that
426 the patch applies to. When this flag is given, and if
427 the original versions of the blobs are available locally,
428 builds a temporary index containing those blobs.
429 </p>
430 <div class="para"><p>When a pure mode change is encountered (which has no index information),
431 the information is read from the current index instead.</p></div>
432 </dd>
433 <dt>
435 </dt>
436 <dt>
437 --reverse
438 </dt>
439 <dd>
441 Apply the patch in reverse.
442 </p>
443 </dd>
444 <dt>
445 --reject
446 </dt>
447 <dd>
449 For atomicity, <em>git apply</em> by default fails the whole patch and
450 does not touch the working tree when some of the hunks
451 do not apply. This option makes it apply
452 the parts of the patch that are applicable, and leave the
453 rejected hunks in corresponding *.rej files.
454 </p>
455 </dd>
456 <dt>
458 </dt>
459 <dd>
461 When <tt>--numstat</tt> has been given, do not munge pathnames,
462 but use a NUL-terminated machine-readable format.
463 </p>
464 <div class="para"><p>Without this option, each pathname output will have TAB, LF, double quotes,
465 and backslash characters replaced with <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt>, and <tt>\\</tt>,
466 respectively, and the pathname will be enclosed in double quotes if
467 any of those replacements occurred.</p></div>
468 </dd>
469 <dt>
470 -p&lt;n&gt;
471 </dt>
472 <dd>
474 Remove &lt;n&gt; leading slashes from traditional diff paths. The
475 default is 1.
476 </p>
477 </dd>
478 <dt>
479 -C&lt;n&gt;
480 </dt>
481 <dd>
483 Ensure at least &lt;n&gt; lines of surrounding context match before
484 and after each change. When fewer lines of surrounding
485 context exist they all must match. By default no context is
486 ever ignored.
487 </p>
488 </dd>
489 <dt>
490 --unidiff-zero
491 </dt>
492 <dd>
494 By default, <em>git apply</em> expects that the patch being
495 applied is a unified diff with at least one line of context.
496 This provides good safety measures, but breaks down when
497 applying a diff generated with <tt>--unified=0</tt>. To bypass these
498 checks use <tt>--unidiff-zero</tt>.
499 </p>
500 <div class="para"><p>Note, for the reasons stated above usage of context-free patches is
501 discouraged.</p></div>
502 </dd>
503 <dt>
504 --apply
505 </dt>
506 <dd>
508 If you use any of the options marked "Turns off
509 <em>apply</em>" above, <em>git apply</em> reads and outputs the
510 requested information without actually applying the
511 patch. Give this flag after those flags to also apply
512 the patch.
513 </p>
514 </dd>
515 <dt>
516 --no-add
517 </dt>
518 <dd>
520 When applying a patch, ignore additions made by the
521 patch. This can be used to extract the common part between
522 two files by first running <em>diff</em> on them and applying
523 the result with this option, which would apply the
524 deletion part but not the addition part.
525 </p>
526 </dd>
527 <dt>
528 --allow-binary-replacement
529 </dt>
530 <dt>
531 --binary
532 </dt>
533 <dd>
535 Historically we did not allow binary patch applied
536 without an explicit permission from the user, and this
537 flag was the way to do so. Currently we always allow binary
538 patch application, so this is a no-op.
539 </p>
540 </dd>
541 <dt>
542 --exclude=&lt;path-pattern&gt;
543 </dt>
544 <dd>
546 Don't apply changes to files matching the given path pattern. This can
547 be useful when importing patchsets, where you want to exclude certain
548 files or directories.
549 </p>
550 </dd>
551 <dt>
552 --include=&lt;path-pattern&gt;
553 </dt>
554 <dd>
556 Apply changes to files matching the given path pattern. This can
557 be useful when importing patchsets, where you want to include certain
558 files or directories.
559 </p>
560 <div class="para"><p>When <tt>--exclude</tt> and <tt>--include</tt> patterns are used, they are examined in the
561 order they appear on the command line, and the first match determines if a
562 patch to each path is used. A patch to a path that does not match any
563 include/exclude pattern is used by default if there is no include pattern
564 on the command line, and ignored if there is any include pattern.</p></div>
565 </dd>
566 <dt>
567 --ignore-space-change
568 </dt>
569 <dt>
570 --ignore-whitespace
571 </dt>
572 <dd>
574 When applying a patch, ignore changes in whitespace in context
575 lines if necessary.
576 Context lines will preserve their whitespace, and they will not
577 undergo whitespace fixing regardless of the value of the
578 <tt>--whitespace</tt> option. New lines will still be fixed, though.
579 </p>
580 </dd>
581 <dt>
582 --whitespace=&lt;action&gt;
583 </dt>
584 <dd>
586 When applying a patch, detect a new or modified line that has
587 whitespace errors. What are considered whitespace errors is
588 controlled by <tt>core.whitespace</tt> configuration. By default,
589 trailing whitespaces (including lines that solely consist of
590 whitespaces) and a space character that is immediately followed
591 by a tab character inside the initial indent of the line are
592 considered whitespace errors.
593 </p>
594 <div class="para"><p>By default, the command outputs warning messages but applies the patch.
595 When <tt>git-apply</tt> is used for statistics and not applying a
596 patch, it defaults to <tt>nowarn</tt>.</p></div>
597 <div class="para"><p>You can use different <tt>&lt;action&gt;</tt> values to control this
598 behavior:</p></div>
599 <div class="ilist"><ul>
600 <li>
602 <tt>nowarn</tt> turns off the trailing whitespace warning.
603 </p>
604 </li>
605 <li>
607 <tt>warn</tt> outputs warnings for a few such errors, but applies the
608 patch as-is (default).
609 </p>
610 </li>
611 <li>
613 <tt>fix</tt> outputs warnings for a few such errors, and applies the
614 patch after fixing them (<tt>strip</tt> is a synonym --- the tool
615 used to consider only trailing whitespace characters as errors, and the
616 fix involved <em>stripping</em> them, but modern gits do more).
617 </p>
618 </li>
619 <li>
621 <tt>error</tt> outputs warnings for a few such errors, and refuses
622 to apply the patch.
623 </p>
624 </li>
625 <li>
627 <tt>error-all</tt> is similar to <tt>error</tt> but shows all errors.
628 </p>
629 </li>
630 </ul></div>
631 </dd>
632 <dt>
633 --inaccurate-eof
634 </dt>
635 <dd>
637 Under certain circumstances, some versions of <em>diff</em> do not correctly
638 detect a missing new-line at the end of the file. As a result, patches
639 created by such <em>diff</em> programs do not record incomplete lines
640 correctly. This option adds support for applying such patches by
641 working around this bug.
642 </p>
643 </dd>
644 <dt>
646 </dt>
647 <dt>
648 --verbose
649 </dt>
650 <dd>
652 Report progress to stderr. By default, only a message about the
653 current patch being applied will be printed. This option will cause
654 additional information to be reported.
655 </p>
656 </dd>
657 <dt>
658 --recount
659 </dt>
660 <dd>
662 Do not trust the line counts in the hunk headers, but infer them
663 by inspecting the patch (e.g. after editing the patch without
664 adjusting the hunk headers appropriately).
665 </p>
666 </dd>
667 <dt>
668 --directory=&lt;root&gt;
669 </dt>
670 <dd>
672 Prepend &lt;root&gt; to all filenames. If a "-p" argument was also passed,
673 it is applied before prepending the new root.
674 </p>
675 <div class="para"><p>For example, a patch that talks about updating <tt>a/git-gui.sh</tt> to <tt>b/git-gui.sh</tt>
676 can be applied to the file in the working tree <tt>modules/git-gui/git-gui.sh</tt> by
677 running <tt>git apply --directory=modules/git-gui</tt>.</p></div>
678 </dd>
679 </dl></div>
680 </div>
681 <h2 id="_configuration">Configuration</h2>
682 <div class="sectionbody">
683 <div class="vlist"><dl>
684 <dt>
685 apply.ignorewhitespace
686 </dt>
687 <dd>
689 Set to <em>change</em> if you want changes in whitespace to be ignored by default.
690 Set to one of: no, none, never, false if you want changes in
691 whitespace to be significant.
692 </p>
693 </dd>
694 <dt>
695 apply.whitespace
696 </dt>
697 <dd>
699 When no <tt>--whitespace</tt> flag is given from the command
700 line, this configuration item is used as the default.
701 </p>
702 </dd>
703 </dl></div>
704 </div>
705 <h2 id="_submodules">Submodules</h2>
706 <div class="sectionbody">
707 <div class="para"><p>If the patch contains any changes to submodules then <em>git apply</em>
708 treats these changes as follows.</p></div>
709 <div class="para"><p>If <tt>--index</tt> is specified (explicitly or implicitly), then the submodule
710 commits must match the index exactly for the patch to apply. If any
711 of the submodules are checked-out, then these check-outs are completely
712 ignored, i.e., they are not required to be up-to-date or clean and they
713 are not updated.</p></div>
714 <div class="para"><p>If <tt>--index</tt> is not specified, then the submodule commits in the patch
715 are ignored and only the absence or presence of the corresponding
716 subdirectory is checked and (if possible) updated.</p></div>
717 </div>
718 <h2 id="_author">Author</h2>
719 <div class="sectionbody">
720 <div class="para"><p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p></div>
721 </div>
722 <h2 id="_documentation">Documentation</h2>
723 <div class="sectionbody">
724 <div class="para"><p>Documentation by Junio C Hamano</p></div>
725 </div>
726 <h2 id="_git">GIT</h2>
727 <div class="sectionbody">
728 <div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
729 </div>
730 <div id="footer">
731 <div id="footer-text">
732 Last updated 2010-01-21 17:44:21 UTC
733 </div>
734 </div>
735 </body>
736 </html>