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