Merge git://
[git/git.git] / Documentation / git-apply.txt
1 git-apply(1)
2 ============
5 ----
6 git-apply - Apply patch on a git index file and a work tree
10 --------
11 [verse]
12 'git-apply' [--stat] [--numstat] [--summary] [--check] [--index] [--apply]
13 [--no-add] [--index-info] [--allow-binary-replacement] [-z] [-pNUM]
14 [<patch>...]
17 -----------
18 Reads supplied diff output and applies it on a git index file
19 and a work tree.
22 -------
23 <patch>...::
24 The files to read patch from. '-' can be used to read
25 from the standard input.
27 --stat::
28 Instead of applying the patch, output diffstat for the
29 input. Turns off "apply".
31 --numstat::
32 Similar to \--stat, but shows number of added and
33 deleted lines in decimal notation and pathname without
34 abbreviation, to make it more machine friendly. Turns
35 off "apply".
37 --summary::
38 Instead of applying the patch, output a condensed
39 summary of information obtained from git diff extended
40 headers, such as creations, renames and mode changes.
41 Turns off "apply".
43 --check::
44 Instead of applying the patch, see if the patch is
45 applicable to the current work tree and/or the index
46 file and detects errors. Turns off "apply".
48 --index::
49 When --check is in effect, or when applying the patch
50 (which is the default when none of the options that
51 disables it is in effect), make sure the patch is
52 applicable to what the current index file records. If
53 the file to be patched in the work tree is not
54 up-to-date, it is flagged as an error. This flag also
55 causes the index file to be updated.
57 --index-info::
58 Newer git-diff output has embedded 'index information'
59 for each blob to help identify the original version that
60 the patch applies to. When this flag is given, and if
61 the original version of the blob is available locally,
62 outputs information about them to the standard output.
64 -z::
65 When showing the index information, do not munge paths,
66 but use NUL terminated machine readable format. Without
67 this flag, the pathnames output will have TAB, LF, and
68 backslash characters replaced with `\t`, `\n`, and `\\`,
69 respectively.
71 -p<n>::
72 Remove <n> leading slashes from traditional diff paths. The
73 default is 1.
75 --apply::
76 If you use any of the options marked ``Turns off
77 "apply"'' above, git-apply reads and outputs the
78 information you asked without actually applying the
79 patch. Give this flag after those flags to also apply
80 the patch.
82 --no-add::
83 When applying a patch, ignore additions made by the
84 patch. This can be used to extract common part between
85 two files by first running `diff` on them and applying
86 the result with this option, which would apply the
87 deletion part but not addition part.
89 --allow-binary-replacement::
90 When applying a patch, which is a git-enhanced patch
91 that was prepared to record the pre- and post-image object
92 name in full, and the path being patched exactly matches
93 the object the patch applies to (i.e. "index" line's
94 pre-image object name is what is in the working tree),
95 and the post-image object is available in the object
96 database, use the post-image object as the patch
97 result. This allows binary files to be patched in a
98 very limited way.
100 Author
101 ------
102 Written by Linus Torvalds <>
104 Documentation
105 --------------
106 Documentation by Junio C Hamano
108 GIT
109 ---
110 Part of the gitlink:git[7] suite