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 [--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 If you use any of the options marked ``Turns off
78 "apply"'' above, git-apply reads and outputs the
79 information you asked without actually applying the
80 patch. Give this flag after those flags to also apply
84 When applying a patch, ignore additions made by the
85 patch. This can be used to extract common part between
86 two files by first running `diff` on them and applying
87 the result with this option, which would apply the
88 deletion part but not addition part.
90 --allow-binary-replacement::
91 When applying a patch, which is a git-enhanced patch
92 that was prepared to record the pre- and post-image object
93 name in full, and the path being patched exactly matches
94 the object the patch applies to (i.e. "index" line's
95 pre-image object name is what is in the working tree),
96 and the post-image object is available in the object
97 database, use the post-image object as the patch
98 result. This allows binary files to be patched in a
101 --whitespace=<option>::
102 When applying a patch, detect a new or modified line
103 that ends with trailing whitespaces (this includes a
104 line that solely consists of whitespaces). By default,
105 the command outputs warning messages and applies the
107 When `git-apply` is used for statistics and not applying a
108 patch, it defaults to `nowarn`.
109 You can use different `<option>` to control this
112 * `nowarn` turns off the trailing whitespace warning.
113 * `warn` outputs warnings for a few such errors, but applies the
115 * `error` outputs warnings for a few such errors, and refuses
117 * `error-all` is similar to `error` but shows all errors.
118 * `strip` outputs warnings for a few such errors, strips out the
119 trailing whitespaces and applies the patch.
126 When no `--whitespace` flag is given from the command
127 line, this configuration item is used as the default.
132 Written by Linus Torvalds <torvalds@osdl.org>
136 Documentation by Junio C Hamano
140 Part of the gitlink:git[7] suite