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