6 git-apply - Apply patch on a git index file and a work tree
12 'git-apply' [--stat] [--numstat] [--summary] [--check] [--index] [--apply]
13 [--no-add] [--index-info] [--allow-binary-replacement] [-z] [-pNUM]
14 [-CNUM] [--whitespace=<nowarn|warn|error|error-all|strip>]
19 Reads supplied diff output and applies it on a git index file
25 The files to read patch from. '-' can be used to read
26 from the standard input.
29 Instead of applying the patch, output diffstat for the
30 input. Turns off "apply".
33 Similar to \--stat, but shows number of added and
34 deleted lines in decimal notation and pathname without
35 abbreviation, to make it more machine friendly. Turns
39 Instead of applying the patch, output a condensed
40 summary of information obtained from git diff extended
41 headers, such as creations, renames and mode changes.
45 Instead of applying the patch, see if the patch is
46 applicable to the current work tree and/or the index
47 file and detects errors. Turns off "apply".
50 When --check is in effect, or when applying the patch
51 (which is the default when none of the options that
52 disables it is in effect), make sure the patch is
53 applicable to what the current index file records. If
54 the file to be patched in the work tree is not
55 up-to-date, it is flagged as an error. This flag also
56 causes the index file to be updated.
59 Newer git-diff output has embedded 'index information'
60 for each blob to help identify the original version that
61 the patch applies to. When this flag is given, and if
62 the original version of the blob is available locally,
63 outputs information about them to the standard output.
66 When showing the index information, do not munge paths,
67 but use NUL terminated machine readable format. Without
68 this flag, the pathnames output will have TAB, LF, and
69 backslash characters replaced with `\t`, `\n`, and `\\`,
73 Remove <n> leading slashes from traditional diff paths. The
77 Ensure at least <n> lines of surrounding context match before
78 and after each change. When fewer lines of surrounding
79 context exist they all most match. By default no context is
83 If you use any of the options marked ``Turns off
84 "apply"'' above, git-apply reads and outputs the
85 information you asked without actually applying the
86 patch. Give this flag after those flags to also apply
90 When applying a patch, ignore additions made by the
91 patch. This can be used to extract common part between
92 two files by first running `diff` on them and applying
93 the result with this option, which would apply the
94 deletion part but not addition part.
96 --allow-binary-replacement::
97 When applying a patch, which is a git-enhanced patch
98 that was prepared to record the pre- and post-image object
99 name in full, and the path being patched exactly matches
100 the object the patch applies to (i.e. "index" line's
101 pre-image object name is what is in the working tree),
102 and the post-image object is available in the object
103 database, use the post-image object as the patch
104 result. This allows binary files to be patched in a
107 --whitespace=<option>::
108 When applying a patch, detect a new or modified line
109 that ends with trailing whitespaces (this includes a
110 line that solely consists of whitespaces). By default,
111 the command outputs warning messages and applies the
113 When `git-apply` is used for statistics and not applying a
114 patch, it defaults to `nowarn`.
115 You can use different `<option>` to control this
118 * `nowarn` turns off the trailing whitespace warning.
119 * `warn` outputs warnings for a few such errors, but applies the
121 * `error` outputs warnings for a few such errors, and refuses
123 * `error-all` is similar to `error` but shows all errors.
124 * `strip` outputs warnings for a few such errors, strips out the
125 trailing whitespaces and applies the patch.
132 When no `--whitespace` flag is given from the command
133 line, this configuration item is used as the default.
138 Written by Linus Torvalds <torvalds@osdl.org>
142 Documentation by Junio C Hamano
146 Part of the gitlink:git[7] suite