1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.2.5" />
7 <style type=
"text/css">
9 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
11 border: 1px solid red;
16 margin: 1em 5% 1em 5%;
21 text-decoration: underline
;
39 h1
, h2
, h3
, h4
, h5
, h6
{
41 font-family: sans-serif
;
48 border-bottom: 2px solid silver
;
66 border: 1px solid silver
;
81 font-family: sans-serif
;
88 font-family: sans-serif
;
92 font-family: sans-serif
;
94 border-top: 2px solid silver
;
100 padding-bottom: 0.5em;
104 padding-bottom: 0.5em;
108 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
109 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
110 div
.admonitionblock
{
113 margin-bottom: 1.5em;
115 div
.admonitionblock
{
117 margin-bottom: 2.5em;
120 div
.content
{ /* Block element content. */
124 /* Block element titles. */
125 div
.title
, caption
.title
{
126 font-family: sans-serif
;
130 margin-bottom: 0.5em;
136 td div
.title:first-child
{
139 div
.content div
.title:first-child
{
142 div
.content
+ div
.title
{
146 div
.sidebarblock
> div
.content
{
148 border: 1px solid silver
;
155 div
.listingblock
> div
.content
{
156 border: 1px solid silver
;
161 div
.quoteblock
> div
.content
{
168 div
.verseblock
+ div
.attribution
{
172 div
.admonitionblock
.icon
{
176 text-decoration: underline
;
178 padding-right: 0.5em;
180 div
.admonitionblock td
.content
{
182 border-left: 2px solid silver
;
185 div
.exampleblock
> div
.content
{
186 border-left: 2px solid silver
;
190 div
.verseblock div
.content
{
194 div
.imageblock div
.content
{ padding-left: 0; }
195 div
.imageblock img
{ border: 1px solid silver
; }
196 span
.image img
{ border-style: none
; }
200 margin-bottom: 0.8em;
212 list-style-position: outside
;
215 list-style-type: lower-alpha
;
218 div
.tableblock
> table
{
219 border: 3px solid
#527bbd;
222 font-family: sans-serif
;
231 margin-bottom: 0.8em;
239 padding-right: 0.8em;
246 div#footer-badges
{ display: none
; }
251 font-family: sans-serif
;
255 margin-bottom: 0.1em;
258 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
274 include1::./stylesheets
/xhtml11-manpage
.css
[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div
.sidebar-content
{
279 border: 1px solid silver
;
282 div
.sidebar-title
, div
.image-title
{
283 font-family: sans-serif
;
286 margin-bottom: 0.5em;
289 div
.listingblock div
.content
{
290 border: 1px solid silver
;
295 div
.quoteblock-content
{
299 div
.exampleblock-content
{
300 border-left: 2px solid silver
;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc
a:visited
{ color: blue
; }
307 <title>git-format-patch(
1)
</title>
312 git-format-patch(
1) Manual Page
315 <div class=
"sectionbody">
316 <p>git-format-patch -
317 Prepare patches for e-mail submission
322 <div class=
"sectionbody">
323 <div class=
"verseblock">
324 <div class=
"content"><em>git format-patch
</em> [-k] [(-o|--output-directory)
<dir
> | --stdout]
325 [--thread[=
<style
>]]
326 [(--attach|--inline)[=
<boundary
>] | --no-attach]
328 [-n | --numbered | -N | --no-numbered]
329 [--start-number
<n
>] [--numbered-files]
330 [--in-reply-to=Message-Id] [--suffix=.
<sfx
>]
331 [--ignore-if-in-upstream]
332 [--subject-prefix=Subject-Prefix]
335 [
<common diff options
>]
336 [
<since
> |
<revision range
> ]
</div></div>
338 <h2 id=
"_description">DESCRIPTION
</h2>
339 <div class=
"sectionbody">
340 <div class=
"para"><p>Prepare each commit with its patch in
341 one file per commit, formatted to resemble UNIX mailbox format.
342 The output of this command is convenient for e-mail submission or
343 for use with
<em>git-am
</em>.
</p></div>
344 <div class=
"para"><p>There are two ways to specify which commits to operate on.
</p></div>
345 <div class=
"olist"><ol>
348 A single commit,
<since
>, specifies that the commits leading
349 to the tip of the current branch that are not in the history
350 that leads to the
<since
> to be output.
355 Generic
<revision range
> expression (see
"SPECIFYING
356 REVISIONS" section in
<a href=
"git-rev-parse.html">git-rev-parse(
1)
</a>) means the
357 commits in the specified range.
361 <div class=
"para"><p>The first rule takes precedence in the case of a single
<commit
>. To
362 apply the second rule, i.e., format everything since the beginning of
363 history up until
<commit
>, use the
<em>--root
</em> option:
"git format-patch
364 --root <commit>". If you want to format only
<commit
> itself, you
365 can do this with
"git format-patch -1 <commit>".
</p></div>
366 <div class=
"para"><p>By default, each output file is numbered sequentially from
1, and uses the
367 first line of the commit message (massaged for pathname safety) as
368 the filename. With the --numbered-files option, the output file names
369 will only be numbers, without the first line of the commit appended.
370 The names of the output files are printed to standard
371 output, unless the --stdout option is specified.
</p></div>
372 <div class=
"para"><p>If -o is specified, output files are created in
<dir
>. Otherwise
373 they are created in the current working directory.
</p></div>
374 <div class=
"para"><p>By default, the subject of a single patch is
"[PATCH] First Line" and
375 the subject when multiple patches are output is
"[PATCH n/m] First
376 Line". To force
1/
1 to be added for a single patch, use -n. To omit
377 patch numbers from the subject, use -N
</p></div>
378 <div class=
"para"><p>If given --thread,
<em>git-format-patch
</em> will generate In-Reply-To and
379 References headers to make the second and subsequent patch mails appear
380 as replies to the first mail; this also generates a Message-Id header to
383 <h2 id=
"_options">OPTIONS
</h2>
384 <div class=
"sectionbody">
385 <div class=
"vlist"><dl>
391 Generate patches without diffstat.
402 Generate diffs with
<n
> lines of context instead of
403 the usual three. Implies
"-p".
411 Generate the raw format.
420 Synonym for
"-p --raw".
428 Generate a diff using the
"patience diff" algorithm.
432 --stat[=width[,name-width]]
436 Generate a diffstat. You can override the default
437 output width for
80-column terminal by
"--stat=width".
438 The width of the filename part can be controlled by
439 giving another width to it separated by a comma.
447 Similar to --stat, but shows number of added and
448 deleted lines in decimal notation and pathname without
449 abbreviation, to make it more machine friendly. For
450 binary files, outputs two
<tt>-
</tt> instead of saying
459 Output only the last line of the --stat format containing total
460 number of modified files, as well as number of added and deleted
469 Output the distribution of relative amount of changes (number of lines added or
470 removed) for each sub-directory. Directories with changes below
471 a cut-off percent (
3% by default) are not shown. The cut-off percent
472 can be set with
"--dirstat=limit". Changes in a child directory is not
473 counted for the parent directory, unless
"--cumulative" is used.
477 --dirstat-by-file[=limit]
481 Same as --dirstat, but counts changed files instead of lines.
489 Output a condensed summary of extended header information
490 such as creations, renames and mode changes.
498 Synonym for
"-p --stat".
507 NUL-line termination on output. This affects the --raw
508 output field terminator. Also output from commands such
509 as
"git-log" will be delimited with NUL between commits.
517 Show only names of changed files.
525 Show only names and status of changed files. See the description
526 of the
<tt>--diff-filter
</tt> option on what the status letters mean.
542 Turn off colored diff, even when the configuration file
543 gives the default to color output.
547 --color-words[=
<regex
>]
551 Show colored word diff, i.e., color words which have changed.
552 By default, words are separated by whitespace.
554 <div class=
"para"><p>When a
<regex
> is specified, every non-overlapping match of the
555 <regex
> is considered a word. Anything between these matches is
556 considered whitespace and ignored(!) for the purposes of finding
557 differences. You may want to append
<tt>|[^[:space:]]
</tt> to your regular
558 expression to make sure that it matches all non-whitespace characters.
559 A match that contains a newline is silently truncated(!) at the
561 <div class=
"para"><p>The regex can also be set via a diff driver or configuration option, see
562 <a href=
"gitattributes.html">gitattributes(
1)
</a> or
<a href=
"git-config.html">git-config(
1)
</a>. Giving it explicitly
563 overrides any diff driver or configuration setting. Diff drivers
564 override configuration settings.
</p></div>
571 Turn off rename detection, even when the configuration
572 file gives the default to do so.
580 Warn if changes introduce trailing whitespace
581 or an indent that uses a space before a tab. Exits with
582 non-zero status if problems are found. Not compatible with
591 Instead of the first handful of characters, show the full
592 pre- and post-image blob object names on the
"index"
593 line when generating patch format output.
601 In addition to --full-index, output
"binary diff" that
602 can be applied with
"git apply".
610 Instead of showing the full
40-byte hexadecimal object
611 name in diff-raw format output and diff-tree header
612 lines, show only a partial prefix. This is
613 independent of --full-index option above, which controls
614 the diff-patch output format. Non default number of
615 digits can be specified with --abbrev=
<n
>.
623 Break complete rewrite changes into pairs of delete and create.
639 Detect copies as well as renames. See also
<tt>--find-copies-harder
</tt>.
643 --diff-filter=[ACDMRTUXB*]
647 Select only files that are Added (
<tt>A
</tt>), Copied (
<tt>C
</tt>),
648 Deleted (
<tt>D
</tt>), Modified (
<tt>M
</tt>), Renamed (
<tt>R
</tt>), have their
649 type (i.e. regular file, symlink, submodule,
…) changed (
<tt>T
</tt>),
650 are Unmerged (
<tt>U
</tt>), are
651 Unknown (
<tt>X
</tt>), or have had their pairing Broken (
<tt>B
</tt>).
652 Any combination of the filter characters may be used.
653 When
<tt>*
</tt> (All-or-none) is added to the combination, all
654 paths are selected if there is any file that matches
655 other criteria in the comparison; if there is no file
656 that matches other criteria, nothing is selected.
664 For performance reasons, by default,
<tt>-C
</tt> option finds copies only
665 if the original file of the copy was modified in the same
666 changeset. This flag makes the command
667 inspect unmodified files as candidates for the source of
668 copy. This is a very expensive operation for large
669 projects, so use it with caution. Giving more than one
670 <tt>-C
</tt> option has the same effect.
678 -M and -C options require O(n^
2) processing time where n
679 is the number of potential rename/copy targets. This
680 option prevents rename/copy detection from running if
681 the number of rename/copy targets exceeds the specified
690 Look for differences that introduce or remove an instance of
691 <string
>. Note that this is different than the string simply
692 appearing in diff output; see the
<em>pickaxe
</em> entry in
693 <a href=
"gitdiffcore.html">gitdiffcore(
7)
</a> for more details.
701 When -S finds a change, show all the changes in that
702 changeset, not just the files that contain the change
711 Make the
<string
> not a plain string but an extended POSIX
720 Output the patch in the order specified in the
721 <orderfile
>, which has one shell glob pattern per line.
729 Swap two inputs; that is, show differences from index or
730 on-disk file to tree contents.
734 --relative[=
<path
>]
738 When run from a subdirectory of the project, it can be
739 told to exclude changes outside the directory and show
740 pathnames relative to it with this option. When you are
741 not in a subdirectory (e.g. in a bare repository), you
742 can name which subdirectory to make the output relative
743 to by giving a
<path
> as an argument.
754 Treat all files as text.
758 --ignore-space-at-eol
762 Ignore changes in whitespace at EOL.
769 --ignore-space-change
773 Ignore changes in amount of whitespace. This ignores whitespace
774 at line end, and considers all other sequences of one or
775 more whitespace characters to be equivalent.
786 Ignore whitespace when comparing lines. This ignores
787 differences even if one line has whitespace where the other
792 --inter-hunk-context=
<lines
>
796 Show the context between diff hunks, up to the specified number
797 of lines, thereby fusing hunks that are close to each other.
805 Make the program exit with codes similar to diff(
1).
806 That is, it exits with
1 if there were differences and
807 0 means no differences.
815 Disable all output of the program. Implies --exit-code.
823 Allow an external diff helper to be executed. If you set an
824 external diff driver with
<a href=
"gitattributes.html">gitattributes(
5)
</a>, you need
825 to use this option with
<a href=
"git-log.html">git-log(
1)
</a> and friends.
833 Disallow external diff drivers.
841 Ignore changes to submodules in the diff generation.
845 --src-prefix=
<prefix
>
849 Show the given source prefix instead of
"a/".
853 --dst-prefix=
<prefix
>
857 Show the given destination prefix instead of
"b/".
865 Do not show any source or destination prefix.
869 <div class=
"para"><p>For more detailed explanation on these common options, see also
870 <a href=
"gitdiffcore.html">gitdiffcore(
7)
</a>.
</p></div>
871 <div class=
"vlist"><dl>
877 Limits the number of patches to prepare.
884 --output-directory
<dir
>
888 Use
<dir
> to store the resulting files, instead of the
889 current working directory.
900 Name output in
<em>[PATCH n/m]
</em> format, even with a single patch.
911 Name output in
<em>[PATCH]
</em> format.
915 --start-number
<n
>
919 Start numbering the patches at
<n
> instead of
1.
927 Output file names will be a simple number sequence
928 without the default first line of the commit appended.
939 Do not strip/add
<em>[PATCH]
</em> from the first line of the
951 Add
<tt>Signed-off-by:
</tt> line to the commit message, using
952 the committer identity of yourself.
960 Print all commits to the standard output in mbox format,
961 instead of creating a file for each one.
965 --attach[=
<boundary
>]
969 Create multipart/mixed attachment, the first part of
970 which is the commit message and the patch itself in the
971 second part, with
"Content-Disposition: attachment".
979 Disable the creation of an attachment, overriding the
980 configuration setting.
984 --inline[=
<boundary
>]
988 Create multipart/mixed attachment, the first part of
989 which is the commit message and the patch itself in the
990 second part, with
"Content-Disposition: inline".
994 --thread[=
<style
>]
998 Add In-Reply-To and References headers to make the second and
999 subsequent mails appear as replies to the first. Also generates
1000 the Message-Id header to reference.
1002 <div class=
"para"><p>The optional
<style
> argument can be either
<tt>shallow
</tt> or
<tt>deep
</tt>.
1003 <em>shallow
</em> threading makes every mail a reply to the head of the
1004 series, where the head is chosen from the cover letter, the
1005 <tt>--in-reply-to
</tt>, and the first patch mail, in this order.
<em>deep
</em>
1006 threading makes every mail a reply to the previous one. If not
1007 specified, defaults to the
<em>format.thread
</em> configuration, or
<tt>shallow
</tt>
1008 if that is not set.
</p></div>
1011 --in-reply-to=Message-Id
1015 Make the first mail (or all the mails with --no-thread) appear as a
1016 reply to the given Message-Id, which avoids breaking threads to
1017 provide a new patch series.
1021 --ignore-if-in-upstream
1025 Do not include a patch that matches a commit in
1026 <until
>..
<since
>. This will examine all patches reachable
1027 from
<since
> but not from
<until
> and compare them with the
1028 patches being generated, and any patch that matches is
1033 --subject-prefix=
<Subject-Prefix
>
1037 Instead of the standard
<em>[PATCH]
</em> prefix in the subject
1038 line, instead use
<em>[
<Subject-Prefix
>]
</em>. This
1039 allows for useful naming of a patch series, and can be
1040 combined with the --numbered option.
1048 Add a
"Cc:" header to the email headers. This is in addition
1049 to any configured headers, and may be used multiple times.
1053 --add-header=
<header
>
1057 Add an arbitrary header to the email headers. This is in addition
1058 to any configured headers, and may be used multiple times.
1059 For example,
--add-header=
"Organization: git-foo"
1067 In addition to the patches, generate a cover letter file
1068 containing the shortlog and the overall diffstat. You can
1069 fill in a description in the file before sending it out.
1073 --suffix=.
<sfx
>
1077 Instead of using
<tt>.patch
</tt> as the suffix for generated
1078 filenames, use specified suffix. A common alternative is
1079 <tt>--suffix=.txt
</tt>. Leaving this empty will remove the
<tt>.patch
</tt>
1082 <div class=
"para"><p>Note that the leading character does not have to be a dot; for example,
1083 you can use
<tt>--suffix=-patch
</tt> to get
<tt>0001-description-of-my-change-patch
</tt>.
</p></div>
1090 Do not output contents of changes in binary files, instead
1091 display a notice that those files changed. Patches generated
1092 using this option cannot be applied properly, but they are
1093 still useful for code review.
1101 Treat the revision argument as a
<revision range
>, even if it
1102 is just a single commit (that would normally be treated as a
1103 <since
>). Note that root commits included in the specified
1104 range are always formatted as creation patches, independently
1110 <h2 id=
"_configuration">CONFIGURATION
</h2>
1111 <div class=
"sectionbody">
1112 <div class=
"para"><p>You can specify extra mail header lines to be added to each message,
1113 defaults for the subject prefix and file suffix, number patches when
1114 outputting more than one patch, add
"Cc:" headers, configure attachments,
1115 and sign off patches with configuration variables.
</p></div>
1116 <div class=
"listingblock">
1117 <div class=
"content">
1119 headers =
"Organization: git-foo\n"
1120 subjectprefix = CHANGE
1124 attach [ = mime-boundary-string ]
1125 signoff = true
</tt></pre>
1128 <h2 id=
"_examples">EXAMPLES
</h2>
1129 <div class=
"sectionbody">
1130 <div class=
"ilist"><ul>
1133 Extract commits between revisions R1 and R2, and apply them on top of
1134 the current branch using
<em>git-am
</em> to cherry-pick them:
1136 <div class=
"listingblock">
1137 <div class=
"content">
1138 <pre><tt>$ git format-patch -k --stdout R1..R2 | git am -
3 -k
</tt></pre>
1143 Extract all commits which are in the current branch but not in the
1146 <div class=
"listingblock">
1147 <div class=
"content">
1148 <pre><tt>$ git format-patch origin
</tt></pre>
1150 <div class=
"para"><p>For each commit a separate file is created in the current directory.
</p></div>
1154 Extract all commits that lead to
<em>origin
</em> since the inception of the
1157 <div class=
"listingblock">
1158 <div class=
"content">
1159 <pre><tt>$ git format-patch --root origin
</tt></pre>
1164 The same as the previous one:
1166 <div class=
"listingblock">
1167 <div class=
"content">
1168 <pre><tt>$ git format-patch -M -B origin
</tt></pre>
1170 <div class=
"para"><p>Additionally, it detects and handles renames and complete rewrites
1171 intelligently to produce a renaming patch. A renaming patch reduces
1172 the amount of text output, and generally makes it easier to review.
1173 Note that non-git
"patch" programs won't understand renaming patches, so
1174 use it only when you know the recipient uses git to apply your patch.
</p></div>
1178 Extract three topmost commits from the current branch and format them
1179 as e-mailable patches:
1181 <div class=
"listingblock">
1182 <div class=
"content">
1183 <pre><tt>$ git format-patch -
3</tt></pre>
1188 <h2 id=
"_see_also">SEE ALSO
</h2>
1189 <div class=
"sectionbody">
1190 <div class=
"para"><p><a href=
"git-am.html">git-am(
1)
</a>,
<a href=
"git-send-email.html">git-send-email(
1)
</a></p></div>
1192 <h2 id=
"_author">Author
</h2>
1193 <div class=
"sectionbody">
1194 <div class=
"para"><p>Written by Junio C Hamano
<gitster@pobox.com
></p></div>
1196 <h2 id=
"_documentation">Documentation
</h2>
1197 <div class=
"sectionbody">
1198 <div class=
"para"><p>Documentation by Junio C Hamano and the git-list
<git@vger.kernel.org
>.
</p></div>
1200 <h2 id=
"_git">GIT
</h2>
1201 <div class=
"sectionbody">
1202 <div class=
"para"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
1205 <div id=
"footer-text">
1206 Last updated
2009-
04-
25 08:
29:
43 UTC