git-apply --reject
[git/jrn.git] / Documentation / git-apply.txt
blob11641a92e3c3e17714f63e4bb3fd570afa6f44d3
1 git-apply(1)
2 ============
4 NAME
5 ----
6 git-apply - Apply patch on a git index file and a work tree
9 SYNOPSIS
10 --------
11 [verse]
12 'git-apply' [--stat] [--numstat] [--summary] [--check] [--index] [--apply]
13           [--no-add] [--index-info] [--allow-binary-replacement]
14           [--reverse] [--reject] [-z] [-pNUM]
15           [-CNUM] [--whitespace=<nowarn|warn|error|error-all|strip>]
16           [<patch>...]
18 DESCRIPTION
19 -----------
20 Reads supplied diff output and applies it on a git index file
21 and a work tree.
23 OPTIONS
24 -------
25 <patch>...::
26         The files to read patch from.  '-' can be used to read
27         from the standard input.
29 --stat::
30         Instead of applying the patch, output diffstat for the
31         input.  Turns off "apply".
33 --numstat::
34         Similar to \--stat, but shows number of added and
35         deleted lines in decimal notation and pathname without
36         abbreviation, to make it more machine friendly.  Turns
37         off "apply".
39 --summary::
40         Instead of applying the patch, output a condensed
41         summary of information obtained from git diff extended
42         headers, such as creations, renames and mode changes.
43         Turns off "apply".
45 --check::
46         Instead of applying the patch, see if the patch is
47         applicable to the current work tree and/or the index
48         file and detects errors.  Turns off "apply".
50 --index::
51         When --check is in effect, or when applying the patch
52         (which is the default when none of the options that
53         disables it is in effect), make sure the patch is
54         applicable to what the current index file records.  If
55         the file to be patched in the work tree is not
56         up-to-date, it is flagged as an error.  This flag also
57         causes the index file to be updated.
59 --index-info::
60         Newer git-diff output has embedded 'index information'
61         for each blob to help identify the original version that
62         the patch applies to.  When this flag is given, and if
63         the original version of the blob is available locally,
64         outputs information about them to the standard output.
66 --reverse::
67         Apply the patch in reverse.
69 --reject::
70         For atomicity, `git apply` fails the whole patch and
71         does not touch the working tree when some of the hunks
72         do not apply by default.  This option makes it apply
73         parts of the patch that are applicable, and send the
74         rejected hunks to the standard output of the command.
76 -z::
77         When showing the index information, do not munge paths,
78         but use NUL terminated machine readable format.  Without
79         this flag, the pathnames output will have TAB, LF, and
80         backslash characters replaced with `\t`, `\n`, and `\\`,
81         respectively.
83 -p<n>::
84         Remove <n> leading slashes from traditional diff paths. The
85         default is 1.
87 -C<n>::
88         Ensure at least <n> lines of surrounding context match before
89         and after each change.  When fewer lines of surrounding
90         context exist they all must match.  By default no context is
91         ever ignored.
93 --apply::
94         If you use any of the options marked ``Turns off
95         "apply"'' above, git-apply reads and outputs the
96         information you asked without actually applying the
97         patch.  Give this flag after those flags to also apply
98         the patch.
100 --no-add::
101         When applying a patch, ignore additions made by the
102         patch.  This can be used to extract common part between
103         two files by first running `diff` on them and applying
104         the result with this option, which would apply the
105         deletion part but not addition part.
107 --allow-binary-replacement::
108         When applying a patch, which is a git-enhanced patch
109         that was prepared to record the pre- and post-image object
110         name in full, and the path being patched exactly matches
111         the object the patch applies to (i.e. "index" line's
112         pre-image object name is what is in the working tree),
113         and the post-image object is available in the object
114         database, use the post-image object as the patch
115         result.  This allows binary files to be patched in a
116         very limited way.
118 --whitespace=<option>::
119         When applying a patch, detect a new or modified line
120         that ends with trailing whitespaces (this includes a
121         line that solely consists of whitespaces).  By default,
122         the command outputs warning messages and applies the
123         patch.
124         When `git-apply` is used for statistics and not applying a
125         patch, it defaults to `nowarn`.
126         You can use different `<option>` to control this
127         behavior:
129 * `nowarn` turns off the trailing whitespace warning.
130 * `warn` outputs warnings for a few such errors, but applies the
131   patch (default).
132 * `error` outputs warnings for a few such errors, and refuses
133   to apply the patch.
134 * `error-all` is similar to `error` but shows all errors.
135 * `strip` outputs warnings for a few such errors, strips out the
136   trailing whitespaces and applies the patch.
139 Configuration
140 -------------
142 apply.whitespace::
143         When no `--whitespace` flag is given from the command
144         line, this configuration item is used as the default.
147 Author
148 ------
149 Written by Linus Torvalds <torvalds@osdl.org>
151 Documentation
152 --------------
153 Documentation by Junio C Hamano
157 Part of the gitlink:git[7] suite