]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-format-patch.txt
git-ls-files: add --exclude-standard
[thirdparty/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]
6eea60f8 12'git-format-patch' [-k] [-o <dir> | --stdout] [--thread]
2d9e4a47 13 [--attach[=<boundary>] | --inline[=<boundary>]]
e6ff0f42 14 [-s | --signoff] [<common diff options>]
6eea60f8 15 [-n | --numbered | -N | --no-numbered]
e6ff0f42 16 [--start-number <n>] [--numbered-files]
2d9e4a47
RJ
17 [--in-reply-to=Message-Id] [--suffix=.<sfx>]
18 [--ignore-if-in-upstream]
19 [--subject-prefix=Subject-Prefix]
8a1d076e 20 [ <since> | <revision range> ]
7fc9d69f
JH
21
22DESCRIPTION
23-----------
2052d146 24
8a1d076e 25Prepare each commit with its patch in
2052d146 26one file per commit, formatted to resemble UNIX mailbox format.
2052d146
DS
27The output of this command is convenient for e-mail submission or
28for use with gitlink:git-am[1].
35ef3a4c 29
8a1d076e
JH
30There are two ways to specify which commits to operate on.
31
321. A single commit, <since>, specifies that the commits leading
33 to the tip of the current branch that are not in the history
34 that leads to the <since> to be output.
35
362. Generic <revision range> expression (see "SPECIFYING
37 REVISIONS" section in gitlink:git-rev-parse[1]) means the
2f6a3823
JH
38 commits in the specified range.
39
40A single commit, when interpreted as a <revision range>
41expression, means "everything that leads to that commit", but
42if you write 'git format-patch <commit>', the previous rule
43applies to that command line and you do not get "everything
44since the beginning of the time". If you want to format
45everything since project inception to one commit, say "git
46format-patch \--root <commit>" to make it clear that it is the
47latter case.
8a1d076e 48
e6ff0f42 49By default, each output file is numbered sequentially from 1, and uses the
2052d146 50first line of the commit message (massaged for pathname safety) as
e6ff0f42
JL
51the filename. With the --numbered-files option, the output file names
52will only be numbers, without the first line of the commit appended.
53The names of the output files are printed to standard
2052d146 54output, unless the --stdout option is specified.
66f04f38 55
2052d146
DS
56If -o is specified, output files are created in <dir>. Otherwise
57they are created in the current working directory.
35ef3a4c 58
2052d146
DS
59If -n is specified, instead of "[PATCH] Subject", the first line
60is formatted as "[PATCH n/m] Subject".
35ef3a4c 61
cc35de84
JT
62If given --thread, git-format-patch will generate In-Reply-To and
63References headers to make the second and subsequent patch mails appear
64as replies to the first mail; this also generates a Message-Id header to
65reference.
7fc9d69f
JH
66
67OPTIONS
68-------
b8105375
BG
69include::diff-options.txt[]
70
ed5f07a6
MV
71-<n>::
72 Limits the number of patches to prepare.
73
6f855371 74-o|--output-directory <dir>::
35ef3a4c 75 Use <dir> to store the resulting files, instead of the
efd02016 76 current working directory.
35ef3a4c 77
6f855371 78-n|--numbered::
35ef3a4c
JH
79 Name output in '[PATCH n/m]' format.
80
49604a4d
BG
81-N|--no-numbered::
82 Name output in '[PATCH]' format.
83
2052d146
DS
84--start-number <n>::
85 Start numbering the patches at <n> instead of 1.
86
e6ff0f42
JL
87--numbered-files::
88 Output file names will be a simple number sequence
89 without the default first line of the commit appended.
90 Mutually exclusive with the --stdout option.
91
6f855371 92-k|--keep-subject::
35ef3a4c
JH
93 Do not strip/add '[PATCH]' from the first line of the
94 commit log message.
95
6f855371
NW
96-s|--signoff::
97 Add `Signed-off-by:` line to the commit message, using
98 the committer identity of yourself.
99
54ba6013 100--stdout::
2052d146
DS
101 Print all commits to the standard output in mbox format,
102 instead of creating a file for each one.
7fc9d69f 103
c112f689
JS
104--attach[=<boundary>]::
105 Create multipart/mixed attachment, the first part of
106 which is the commit message and the patch itself in the
107 second part, with "Content-Disposition: attachment".
108
109--inline[=<boundary>]::
110 Create multipart/mixed attachment, the first part of
111 which is the commit message and the patch itself in the
112 second part, with "Content-Disposition: inline".
a15a44ef 113
cc35de84
JT
114--thread::
115 Add In-Reply-To and References headers to make the second and
116 subsequent mails appear as replies to the first. Also generates
117 the Message-Id header to reference.
28ffb898 118
da56645d
JT
119--in-reply-to=Message-Id::
120 Make the first mail (or all the mails with --no-thread) appear as a
121 reply to the given Message-Id, which avoids breaking threads to
122 provide a new patch series.
123
cc75ad67
DK
124--ignore-if-in-upstream::
125 Do not include a patch that matches a commit in
126 <until>..<since>. This will examine all patches reachable
127 from <since> but not from <until> and compare them with the
128 patches being generated, and any patch that matches is
129 ignored.
130
2d9e4a47
RJ
131--subject-prefix=<Subject-Prefix>::
132 Instead of the standard '[PATCH]' prefix in the subject
133 line, instead use '[<Subject-Prefix>]'. This
134 allows for useful naming of a patch series, and can be
135 combined with the --numbered option.
136
03eeaeae 137--suffix=.<sfx>::
917a8f89 138 Instead of using `.patch` as the suffix for generated
02783075 139 filenames, use specified suffix. A common alternative is
917a8f89 140 `--suffix=.txt`.
03eeaeae
JH
141+
142Note that you would need to include the leading dot `.` if you
143want a filename like `0001-description-of-my-change.patch`, and
144the first letter does not have to be a dot. Leaving it empty would
145not add any suffix.
146
96ce6d26
MM
147CONFIGURATION
148-------------
49604a4d
BG
149You can specify extra mail header lines to be added to each message
150in the repository configuration, new defaults for the subject prefix
151and file suffix, and number patches when outputting more than one.
96ce6d26 152
917a8f89 153------------
96ce6d26
MM
154[format]
155 headers = "Organization: git-foo\n"
dbd21447 156 subjectprefix = CHANGE
917a8f89 157 suffix = .txt
49604a4d 158 numbered = auto
917a8f89 159------------
03eeaeae 160
96ce6d26 161
28ffb898
JH
162EXAMPLES
163--------
164
165git-format-patch -k --stdout R1..R2 | git-am -3 -k::
166 Extract commits between revisions R1 and R2, and apply
167 them on top of the current branch using `git-am` to
168 cherry-pick them.
169
170git-format-patch origin::
2052d146
DS
171 Extract all commits which are in the current branch but
172 not in the origin branch. For each commit a separate file
173 is created in the current directory.
28ffb898 174
8a1d076e 175git-format-patch \--root origin::
136e6316 176 Extract all commits that lead to 'origin' since the
8a1d076e
JH
177 inception of the project.
178
803f498c 179git-format-patch -M -B origin::
2052d146
DS
180 The same as the previous one. Additionally, it detects
181 and handles renames and complete rewrites intelligently to
182 produce a renaming patch. A renaming patch reduces the
183 amount of text output, and generally makes it easier to
184 review it. Note that the "patch" program does not
185 understand renaming patches, so use it only when you know
186 the recipient uses git to apply your patch.
803f498c 187
7c496280
JH
188git-format-patch -3::
189 Extract three topmost commits from the current branch
190 and format them as e-mailable patches.
28ffb898
JH
191
192See Also
193--------
353ce815 194gitlink:git-am[1], gitlink:git-send-email[1]
28ffb898
JH
195
196
7fc9d69f
JH
197Author
198------
199Written by Junio C Hamano <junkio@cox.net>
200
201Documentation
202--------------
203Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
204
205GIT
206---
a7154e91 207Part of the gitlink:git[7] suite