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