diff --no-index: Do not generate patch output if other output is requested
[git/git.git] / Documentation / git-format-patch.txt
CommitLineData
215a7ad1
JH
1git-format-patch(1)
2===================
7fc9d69f
JH
3
4NAME
5----
7bd7f280 6git-format-patch - Prepare patches for e-mail submission
7fc9d69f
JH
7
8
9SYNOPSIS
10--------
353ce815 11[verse]
b1889c36 12'git format-patch' [-k] [-o <dir> | --stdout] [--thread]
a5a27c79
DB
13 [--attach[=<boundary>] | --inline[=<boundary>]]
14 [-s | --signoff] [<common diff options>]
15 [-n | --numbered | -N | --no-numbered]
16 [--start-number <n>] [--numbered-files]
17 [--in-reply-to=Message-Id] [--suffix=.<sfx>]
18 [--ignore-if-in-upstream]
19 [--subject-prefix=Subject-Prefix]
736cc67d 20 [--cc=<email>]
a5a27c79 21 [--cover-letter]
8a1d076e 22 [ <since> | <revision range> ]
7fc9d69f
JH
23
24DESCRIPTION
25-----------
2052d146 26
8a1d076e 27Prepare each commit with its patch in
2052d146 28one file per commit, formatted to resemble UNIX mailbox format.
2052d146 29The output of this command is convenient for e-mail submission or
ba020ef5 30for use with 'git-am'.
35ef3a4c 31
8a1d076e
JH
32There are two ways to specify which commits to operate on.
33
341. A single commit, <since>, specifies that the commits leading
35 to the tip of the current branch that are not in the history
36 that leads to the <since> to be output.
37
382. Generic <revision range> expression (see "SPECIFYING
5162e697 39 REVISIONS" section in linkgit:git-rev-parse[1]) means the
2f6a3823
JH
40 commits in the specified range.
41
42A single commit, when interpreted as a <revision range>
43expression, means "everything that leads to that commit", but
44if you write 'git format-patch <commit>', the previous rule
45applies to that command line and you do not get "everything
46since the beginning of the time". If you want to format
47everything since project inception to one commit, say "git
48format-patch \--root <commit>" to make it clear that it is the
16088d88
JH
49latter case. If you want to format a single commit, you can do
50this with "git format-patch -1 <commit>".
8a1d076e 51
e6ff0f42 52By default, each output file is numbered sequentially from 1, and uses the
2052d146 53first line of the commit message (massaged for pathname safety) as
e6ff0f42
JL
54the filename. With the --numbered-files option, the output file names
55will only be numbers, without the first line of the commit appended.
56The names of the output files are printed to standard
2052d146 57output, unless the --stdout option is specified.
66f04f38 58
2052d146
DS
59If -o is specified, output files are created in <dir>. Otherwise
60they are created in the current working directory.
35ef3a4c 61
a567fdcb
BG
62By default, the subject of a single patch is "[PATCH] First Line" and
63the subject when multiple patches are output is "[PATCH n/m] First
64Line". To force 1/1 to be added for a single patch, use -n. To omit
65patch numbers from the subject, use -N
35ef3a4c 66
ba020ef5 67If given --thread, 'git-format-patch' will generate In-Reply-To and
cc35de84
JT
68References headers to make the second and subsequent patch mails appear
69as replies to the first mail; this also generates a Message-Id header to
70reference.
7fc9d69f
JH
71
72OPTIONS
73-------
c1a95fa6 74:git-format-patch: 1
b8105375
BG
75include::diff-options.txt[]
76
ed5f07a6
MV
77-<n>::
78 Limits the number of patches to prepare.
79
3240240f
SB
80-o <dir>::
81--output-directory <dir>::
35ef3a4c 82 Use <dir> to store the resulting files, instead of the
efd02016 83 current working directory.
35ef3a4c 84
3240240f
SB
85-n::
86--numbered::
a567fdcb 87 Name output in '[PATCH n/m]' format, even with a single patch.
35ef3a4c 88
3240240f
SB
89-N::
90--no-numbered::
49604a4d
BG
91 Name output in '[PATCH]' format.
92
2052d146
DS
93--start-number <n>::
94 Start numbering the patches at <n> instead of 1.
95
e6ff0f42
JL
96--numbered-files::
97 Output file names will be a simple number sequence
98 without the default first line of the commit appended.
99 Mutually exclusive with the --stdout option.
100
3240240f
SB
101-k::
102--keep-subject::
35ef3a4c
JH
103 Do not strip/add '[PATCH]' from the first line of the
104 commit log message.
105
3240240f
SB
106-s::
107--signoff::
6f855371
NW
108 Add `Signed-off-by:` line to the commit message, using
109 the committer identity of yourself.
110
54ba6013 111--stdout::
2052d146
DS
112 Print all commits to the standard output in mbox format,
113 instead of creating a file for each one.
7fc9d69f 114
c112f689
JS
115--attach[=<boundary>]::
116 Create multipart/mixed attachment, the first part of
117 which is the commit message and the patch itself in the
118 second part, with "Content-Disposition: attachment".
119
120--inline[=<boundary>]::
121 Create multipart/mixed attachment, the first part of
122 which is the commit message and the patch itself in the
123 second part, with "Content-Disposition: inline".
a15a44ef 124
cc35de84
JT
125--thread::
126 Add In-Reply-To and References headers to make the second and
127 subsequent mails appear as replies to the first. Also generates
128 the Message-Id header to reference.
28ffb898 129
da56645d
JT
130--in-reply-to=Message-Id::
131 Make the first mail (or all the mails with --no-thread) appear as a
132 reply to the given Message-Id, which avoids breaking threads to
133 provide a new patch series.
134
cc75ad67
DK
135--ignore-if-in-upstream::
136 Do not include a patch that matches a commit in
137 <until>..<since>. This will examine all patches reachable
138 from <since> but not from <until> and compare them with the
139 patches being generated, and any patch that matches is
140 ignored.
141
2d9e4a47
RJ
142--subject-prefix=<Subject-Prefix>::
143 Instead of the standard '[PATCH]' prefix in the subject
144 line, instead use '[<Subject-Prefix>]'. This
145 allows for useful naming of a patch series, and can be
146 combined with the --numbered option.
147
736cc67d
DB
148--cc=<email>::
149 Add a "Cc:" header to the email headers. This is in addition
150 to any configured headers, and may be used multiple times.
151
a5a27c79 152--cover-letter::
f4912391
MM
153 In addition to the patches, generate a cover letter file
154 containing the shortlog and the overall diffstat. You can
155 fill in a description in the file before sending it out.
a5a27c79 156
03eeaeae 157--suffix=.<sfx>::
917a8f89 158 Instead of using `.patch` as the suffix for generated
02783075 159 filenames, use specified suffix. A common alternative is
917a8f89 160 `--suffix=.txt`.
03eeaeae
JH
161+
162Note that you would need to include the leading dot `.` if you
163want a filename like `0001-description-of-my-change.patch`, and
164the first letter does not have to be a dot. Leaving it empty would
165not add any suffix.
166
37c22a4b
CMOF
167--no-binary::
168 Don't output contents of changes in binary files, just take note
169 that they differ. Note that this disable the patch to be properly
170 applied. By default the contents of changes in those files are
171 encoded in the patch.
172
96ce6d26
MM
173CONFIGURATION
174-------------
49604a4d
BG
175You can specify extra mail header lines to be added to each message
176in the repository configuration, new defaults for the subject prefix
177and file suffix, and number patches when outputting more than one.
96ce6d26 178
917a8f89 179------------
96ce6d26 180[format]
7f9d77f2
JN
181 headers = "Organization: git-foo\n"
182 subjectprefix = CHANGE
183 suffix = .txt
184 numbered = auto
fe8928e6 185 cc = <email>
917a8f89 186------------
03eeaeae 187
96ce6d26 188
28ffb898
JH
189EXAMPLES
190--------
191
921177f5 192* Extract commits between revisions R1 and R2, and apply them on top of
ba020ef5 193the current branch using 'git-am' to cherry-pick them:
921177f5
CC
194+
195------------
467c0197 196$ git format-patch -k --stdout R1..R2 | git am -3 -k
921177f5
CC
197------------
198
199* Extract all commits which are in the current branch but not in the
200origin branch:
201+
202------------
203$ git format-patch origin
204------------
205+
206For each commit a separate file is created in the current directory.
207
208* Extract all commits that lead to 'origin' since the inception of the
209project:
210+
211------------
9c67c757 212$ git format-patch --root origin
921177f5
CC
213------------
214
215* The same as the previous one:
216+
217------------
218$ git format-patch -M -B origin
219------------
220+
221Additionally, it detects and handles renames and complete rewrites
222intelligently to produce a renaming patch. A renaming patch reduces
223the amount of text output, and generally makes it easier to review it.
224Note that the "patch" program does not understand renaming patches, so
225use it only when you know the recipient uses git to apply your patch.
226
227* Extract three topmost commits from the current branch and format them
228as e-mailable patches:
229+
230------------
231$ git format-patch -3
232------------
28ffb898 233
56ae8df5 234SEE ALSO
28ffb898 235--------
5162e697 236linkgit:git-am[1], linkgit:git-send-email[1]
28ffb898
JH
237
238
7fc9d69f
JH
239Author
240------
59eb68aa 241Written by Junio C Hamano <gitster@pobox.com>
7fc9d69f
JH
242
243Documentation
244--------------
245Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
246
247GIT
248---
9e1f0a85 249Part of the linkgit:git[1] suite