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">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.5.2" />
7 <title>git-apply(
1)
</title>
8 <style type=
"text/css">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.5em;
116 margin-bottom: 1.5em;
118 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
119 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
120 div
.admonitionblock
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.0em;
131 div
.content
{ /* Block element content. */
135 /* Block element titles. */
136 div
.title
, caption
.title
{
138 font-family: sans-serif
;
142 margin-bottom: 0.5em;
148 td div
.title:first-child
{
151 div
.content div
.title:first-child
{
154 div
.content
+ div
.title
{
158 div
.sidebarblock
> div
.content
{
160 border: 1px solid silver
;
164 div
.listingblock
> div
.content
{
165 border: 1px solid silver
;
170 div
.quoteblock
, div
.verseblock
{
174 border-left: 5px solid
#dddddd;
178 div
.quoteblock
> div
.attribution
{
183 div
.verseblock
> div
.content
{
186 div
.verseblock
> div
.attribution
{
190 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
191 div
.verseblock
+ div
.attribution
{
195 div
.admonitionblock
.icon
{
199 text-decoration: underline
;
201 padding-right: 0.5em;
203 div
.admonitionblock td
.content
{
205 border-left: 3px solid
#dddddd;
208 div
.exampleblock
> div
.content
{
209 border-left: 3px solid
#dddddd;
213 div
.imageblock div
.content
{ padding-left: 0; }
214 span
.image img
{ border-style: none
; }
215 a
.image:visited
{ color: white
; }
219 margin-bottom: 0.8em;
232 list-style-position: outside
;
235 list-style-type: decimal
;
238 list-style-type: lower-alpha
;
241 list-style-type: upper-alpha
;
244 list-style-type: lower-roman
;
247 list-style-type: upper-roman
;
250 div
.compact ul
, div
.compact ol
,
251 div
.compact p
, div
.compact p
,
252 div
.compact div
, div
.compact div
{
254 margin-bottom: 0.1em;
257 div
.tableblock
> table
{
258 border: 3px solid
#527bbd;
260 thead
, p
.table
.header
{
261 font-family: sans-serif
;
273 /* Because the table frame attribute is overriden by CSS in most browsers. */
274 div
.tableblock
> table
[frame
="void"] {
277 div
.tableblock
> table
[frame
="hsides"] {
278 border-left-style: none
;
279 border-right-style: none
;
281 div
.tableblock
> table
[frame
="vsides"] {
282 border-top-style: none
;
283 border-bottom-style: none
;
289 margin-bottom: 0.8em;
292 padding-bottom: 15px;
294 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
300 padding-right: 0.8em;
306 div
.hdlist
.compact tr
{
315 .footnote, .footnoteref {
319 span
.footnote
, span
.footnoteref
{
320 vertical-align: super
;
324 margin: 20px 0 20px 0;
328 #footnotes div
.footnote
{
334 border-top: 1px solid silver
;
344 div#footer-badges
{ display: none
; }
348 margin-bottom: 2.5em;
353 font-family: sans-serif
;
357 margin-bottom: 0.1em;
360 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
376 /* Overrides for manpage documents */
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver
;
381 border-bottom: 2px solid silver
;
391 div#toc
{ display: none
; }
394 /* Workarounds for IE6's broken and incomplete CSS2. */
396 div
.sidebar-content
{
398 border: 1px solid silver
;
401 div
.sidebar-title
, div
.image-title
{
403 font-family: sans-serif
;
406 margin-bottom: 0.5em;
409 div
.listingblock div
.content
{
410 border: 1px solid silver
;
415 div
.quoteblock-attribution
{
420 div
.verseblock-content
{
423 div
.verseblock-attribution
{
428 div
.exampleblock-content
{
429 border-left: 3px solid
#dddddd;
433 /* IE6 sets dynamically generated links as visited. */
434 div#toc
a:visited
{ color: blue
; }
436 <script type=
"text/javascript">
438 window
.onload = function(){asciidoc
.footnotes();}
439 var asciidoc
= { // Namespace.
441 /////////////////////////////////////////////////////////////////////
442 // Table Of Contents generator
443 /////////////////////////////////////////////////////////////////////
445 /* Author: Mihai Bazon, September 2002
446 * http://students.infoiasi.ro/~mishoo
448 * Table Of Content generator
451 * Feel free to use this script under the terms of the GNU General Public
452 * License, as long as you do not remove or alter this notice.
455 /* modified by Troy D. Hanson, September 2006. License: GPL */
456 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
459 toc: function (toclevels
) {
461 function getText(el
) {
463 for (var i
= el
.firstChild
; i
!= null; i
= i
.nextSibling
) {
464 if (i
.nodeType
== 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
466 else if (i
.firstChild
!= null)
472 function TocEntry(el
, text
, toclevel
) {
475 this.toclevel
= toclevel
;
478 function tocEntries(el
, toclevels
) {
479 var result
= new Array
;
480 var re
= new RegExp('[hH]([2-'+(toclevels
+1)+'])');
481 // Function that scans the DOM tree for header elements (the DOM2
482 // nodeIterator API would be a better technique but not supported by all
484 var iterate = function (el
) {
485 for (var i
= el
.firstChild
; i
!= null; i
= i
.nextSibling
) {
486 if (i
.nodeType
== 1 /* Node.ELEMENT_NODE */) {
487 var mo
= re
.exec(i
.tagName
);
488 if (mo
&& (i
.getAttribute("class") || i
.getAttribute("className")) != "float") {
489 result
[result
.length
] = new TocEntry(i
, getText(i
), mo
[1]-1);
499 var toc
= document
.getElementById("toc");
500 var entries
= tocEntries(document
.getElementById("content"), toclevels
);
501 for (var i
= 0; i
< entries
.length
; ++i
) {
502 var entry
= entries
[i
];
503 if (entry
.element
.id
== "")
504 entry
.element
.id
= "_toc_" + i
;
505 var a
= document
.createElement("a");
506 a
.href
= "#" + entry
.element
.id
;
507 a
.appendChild(document
.createTextNode(entry
.text
));
508 var div
= document
.createElement("div");
510 div
.className
= "toclevel" + entry
.toclevel
;
511 toc
.appendChild(div
);
513 if (entries
.length
== 0)
514 toc
.parentNode
.removeChild(toc
);
518 /////////////////////////////////////////////////////////////////////
519 // Footnotes generator
520 /////////////////////////////////////////////////////////////////////
522 /* Based on footnote generation code from:
523 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
526 footnotes: function () {
527 var cont
= document
.getElementById("content");
528 var noteholder
= document
.getElementById("footnotes");
529 var spans
= cont
.getElementsByTagName("span");
532 for (i
=0; i
<spans
.length
; i
++) {
533 if (spans
[i
].className
== "footnote") {
535 // Use [\s\S] in place of . so multi-line matches work.
536 // Because JavaScript has no s (dotall) regex flag.
537 note
= spans
[i
].innerHTML
.match(/\s*\[([\s\S]*)]\s*/)[1];
538 noteholder
.innerHTML
+=
539 "<div class='footnote' id='_footnote_" + n
+ "'>" +
540 "<a href='#_footnoteref_" + n
+ "' title='Return to text'>" +
541 n
+ "</a>. " + note
+ "</div>";
543 "[<a id='_footnoteref_" + n
+ "' href='#_footnote_" + n
+
544 "' title='View footnote' class='footnote'>" + n
+ "</a>]";
545 var id
=spans
[i
].getAttribute("id");
546 if (id
!= null) refs
["#"+id
] = n
;
550 noteholder
.parentNode
.removeChild(noteholder
);
552 // Process footnoterefs.
553 for (i
=0; i
<spans
.length
; i
++) {
554 if (spans
[i
].className
== "footnoteref") {
555 var href
= spans
[i
].getElementsByTagName("a")[0].getAttribute("href");
556 href
= href
.match(/#.*/)[0]; // Because IE return full URL.
559 "[<a href='#_footnote_" + n
+
560 "' title='View footnote' class='footnote'>" + n
+ "</a>]";
573 git-apply(
1) Manual Page
576 <div class=
"sectionbody">
578 Apply a patch to files and/or to the index
583 <h2 id=
"_synopsis">SYNOPSIS
</h2>
584 <div class=
"sectionbody">
585 <div class=
"verseblock">
586 <div class=
"verseblock-content"><em>git apply
</em> [--stat] [--numstat] [--summary] [--check] [--index]
587 [--apply] [--no-add] [--build-fake-ancestor=
<file
>] [-R | --reverse]
588 [--allow-binary-replacement | --binary] [--reject] [-z]
589 [-p
<n
>] [-C
<n
>] [--inaccurate-eof] [--recount] [--cached]
590 [--ignore-space-change | --ignore-whitespace ]
591 [--whitespace=(nowarn|warn|fix|error|error-all)]
592 [--exclude=
<path
>] [--include=
<path
>] [--directory=
<root
>]
593 [--verbose] [
<patch
>…]
</div>
594 <div class=
"verseblock-attribution">
597 <h2 id=
"_description">DESCRIPTION
</h2>
598 <div class=
"sectionbody">
599 <div class=
"paragraph"><p>Reads the supplied diff output (i.e.
"a patch") and applies it to files.
600 With the
<tt>--index
</tt> option the patch is also applied to the index, and
601 with the
<tt>--cached
</tt> option the patch is only applied to the index.
602 Without these options, the command applies the patch only to files,
603 and does not require them to be in a git repository.
</p></div>
604 <div class=
"paragraph"><p>This command applies the patch but does not create a commit. Use
605 <a href=
"git-am.html">git-am(
1)
</a> to create commits from patches generated by
606 <a href=
"git-format-patch.html">git-format-patch(
1)
</a> and/or received by email.
</p></div>
608 <h2 id=
"_options">OPTIONS
</h2>
609 <div class=
"sectionbody">
610 <div class=
"dlist"><dl>
616 The files to read the patch from.
<em>-
</em> can be used to read
617 from the standard input.
625 Instead of applying the patch, output diffstat for the
626 input. Turns off
"apply".
634 Similar to
<tt>--stat
</tt>, but shows the number of added and
635 deleted lines in decimal notation and the pathname without
636 abbreviation, to make it more machine friendly. For
637 binary files, outputs two
<tt>-
</tt> instead of saying
638 <tt>0 0</tt>. Turns off
"apply".
646 Instead of applying the patch, output a condensed
647 summary of information obtained from git diff extended
648 headers, such as creations, renames and mode changes.
657 Instead of applying the patch, see if the patch is
658 applicable to the current working tree and/or the index
659 file and detects errors. Turns off
"apply".
667 When
<tt>--check
</tt> is in effect, or when applying the patch
668 (which is the default when none of the options that
669 disables it is in effect), make sure the patch is
670 applicable to what the current index file records. If
671 the file to be patched in the working tree is not
672 up-to-date, it is flagged as an error. This flag also
673 causes the index file to be updated.
681 Apply a patch without touching the working tree. Instead take the
682 cached data, apply the patch, and store the result in the index
683 without using the working tree. This implies
<tt>--index
</tt>.
687 --build-fake-ancestor=
<file
>
691 Newer
<em>git diff
</em> output has embedded
<em>index information
</em>
692 for each blob to help identify the original version that
693 the patch applies to. When this flag is given, and if
694 the original versions of the blobs are available locally,
695 builds a temporary index containing those blobs.
697 <div class=
"paragraph"><p>When a pure mode change is encountered (which has no index information),
698 the information is read from the current index instead.
</p></div>
708 Apply the patch in reverse.
716 For atomicity,
<em>git apply
</em> by default fails the whole patch and
717 does not touch the working tree when some of the hunks
718 do not apply. This option makes it apply
719 the parts of the patch that are applicable, and leave the
720 rejected hunks in corresponding *.rej files.
728 When
<tt>--numstat
</tt> has been given, do not munge pathnames,
729 but use a NUL-terminated machine-readable format.
731 <div class=
"paragraph"><p>Without this option, each pathname output will have TAB, LF, double quotes,
732 and backslash characters replaced with
<tt>\t
</tt>,
<tt>\n
</tt>,
<tt>\
"</tt>, and <tt>\\</tt>,
733 respectively, and the pathname will be enclosed in double quotes if
734 any of those replacements occurred.</p></div>
741 Remove <n> leading slashes from traditional diff paths. The
750 Ensure at least <n> lines of surrounding context match before
751 and after each change. When fewer lines of surrounding
752 context exist they all must match. By default no context is
761 By default, <em>git apply</em> expects that the patch being
762 applied is a unified diff with at least one line of context.
763 This provides good safety measures, but breaks down when
764 applying a diff generated with <tt>--unified=0</tt>. To bypass these
765 checks use <tt>--unidiff-zero</tt>.
767 <div class="paragraph
"><p>Note, for the reasons stated above usage of context-free patches is
768 discouraged.</p></div>
775 If you use any of the options marked "Turns off
776 <em>apply
</em>" above, <em>git apply</em> reads and outputs the
777 requested information without actually applying the
778 patch. Give this flag after those flags to also apply
787 When applying a patch, ignore additions made by the
788 patch. This can be used to extract the common part between
789 two files by first running <em>diff</em> on them and applying
790 the result with this option, which would apply the
791 deletion part but not the addition part.
795 --allow-binary-replacement
802 Historically we did not allow binary patch applied
803 without an explicit permission from the user, and this
804 flag was the way to do so. Currently we always allow binary
805 patch application, so this is a no-op.
809 --exclude=<path-pattern>
813 Don’t apply changes to files matching the given path pattern. This can
814 be useful when importing patchsets, where you want to exclude certain
815 files or directories.
819 --include=<path-pattern>
823 Apply changes to files matching the given path pattern. This can
824 be useful when importing patchsets, where you want to include certain
825 files or directories.
827 <div class="paragraph
"><p>When <tt>--exclude</tt> and <tt>--include</tt> patterns are used, they are examined in the
828 order they appear on the command line, and the first match determines if a
829 patch to each path is used. A patch to a path that does not match any
830 include/exclude pattern is used by default if there is no include pattern
831 on the command line, and ignored if there is any include pattern.</p></div>
834 --ignore-space-change
841 When applying a patch, ignore changes in whitespace in context
843 Context lines will preserve their whitespace, and they will not
844 undergo whitespace fixing regardless of the value of the
845 <tt>--whitespace</tt> option. New lines will still be fixed, though.
849 --whitespace=<action>
853 When applying a patch, detect a new or modified line that has
854 whitespace errors. What are considered whitespace errors is
855 controlled by <tt>core.whitespace</tt> configuration. By default,
856 trailing whitespaces (including lines that solely consist of
857 whitespaces) and a space character that is immediately followed
858 by a tab character inside the initial indent of the line are
859 considered whitespace errors.
861 <div class="paragraph
"><p>By default, the command outputs warning messages but applies the patch.
862 When <tt>git-apply</tt> is used for statistics and not applying a
863 patch, it defaults to <tt>nowarn</tt>.</p></div>
864 <div class="paragraph
"><p>You can use different <tt><action></tt> values to control this
866 <div class="ulist
"><ul>
869 <tt>nowarn</tt> turns off the trailing whitespace warning.
874 <tt>warn</tt> outputs warnings for a few such errors, but applies the
875 patch as-is (default).
880 <tt>fix</tt> outputs warnings for a few such errors, and applies the
881 patch after fixing them (<tt>strip</tt> is a synonym --- the tool
882 used to consider only trailing whitespace characters as errors, and the
883 fix involved <em>stripping</em> them, but modern gits do more).
888 <tt>error</tt> outputs warnings for a few such errors, and refuses
894 <tt>error-all</tt> is similar to <tt>error</tt> but shows all errors.
904 Under certain circumstances, some versions of <em>diff</em> do not correctly
905 detect a missing new-line at the end of the file. As a result, patches
906 created by such <em>diff</em> programs do not record incomplete lines
907 correctly. This option adds support for applying such patches by
908 working around this bug.
919 Report progress to stderr. By default, only a message about the
920 current patch being applied will be printed. This option will cause
921 additional information to be reported.
929 Do not trust the line counts in the hunk headers, but infer them
930 by inspecting the patch (e.g. after editing the patch without
931 adjusting the hunk headers appropriately).
935 --directory=<root>
939 Prepend <root> to all filenames. If a "-p
" argument was also passed,
940 it is applied before prepending the new root.
942 <div class="paragraph
"><p>For example, a patch that talks about updating <tt>a/git-gui.sh</tt> to <tt>b/git-gui.sh</tt>
943 can be applied to the file in the working tree <tt>modules/git-gui/git-gui.sh</tt> by
944 running <tt>git apply --directory=modules/git-gui</tt>.</p></div>
948 <h2 id="_configuration
">Configuration</h2>
949 <div class="sectionbody
">
950 <div class="dlist
"><dl>
952 apply.ignorewhitespace
956 Set to <em>change</em> if you want changes in whitespace to be ignored by default.
957 Set to one of: no, none, never, false if you want changes in
958 whitespace to be significant.
966 When no <tt>--whitespace</tt> flag is given from the command
967 line, this configuration item is used as the default.
972 <h2 id="_submodules
">Submodules</h2>
973 <div class="sectionbody
">
974 <div class="paragraph
"><p>If the patch contains any changes to submodules then <em>git apply</em>
975 treats these changes as follows.</p></div>
976 <div class="paragraph
"><p>If <tt>--index</tt> is specified (explicitly or implicitly), then the submodule
977 commits must match the index exactly for the patch to apply. If any
978 of the submodules are checked-out, then these check-outs are completely
979 ignored, i.e., they are not required to be up-to-date or clean and they
980 are not updated.</p></div>
981 <div class="paragraph
"><p>If <tt>--index</tt> is not specified, then the submodule commits in the patch
982 are ignored and only the absence or presence of the corresponding
983 subdirectory is checked and (if possible) updated.</p></div>
985 <h2 id="_see_also
">SEE ALSO</h2>
986 <div class="sectionbody
">
987 <div class="paragraph
"><p><a href="git-am.html
">git-am(1)</a>.</p></div>
989 <h2 id="_git
">GIT</h2>
990 <div class="sectionbody
">
991 <div class="paragraph
"><p>Part of the <a href="git.html
">git(1)</a> suite</p></div>
994 <div id="footnotes
"><hr /></div>
996 <div id="footer-text
">
997 Last updated 2011-09-21 23:01:14 PDT