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