Home Explore Blog CI



git

1st chunk of `Documentation/git-format-patch.adoc`
9a0d7deeeb4475e8e248c30066ddd3b443f8a5d31f13608c0000000100000fa3
git-format-patch(1)
===================

NAME
----
git-format-patch - Prepare patches for e-mail submission


SYNOPSIS
--------
[verse]
'git format-patch' [-k] [(-o|--output-directory) <dir> | --stdout]
		   [--no-thread | --thread[=<style>]]
		   [(--attach|--inline)[=<boundary>] | --no-attach]
		   [-s | --signoff]
		   [--signature=<signature> | --no-signature]
		   [--signature-file=<file>]
		   [-n | --numbered | -N | --no-numbered]
		   [--start-number <n>] [--numbered-files]
		   [--in-reply-to=<message-id>] [--suffix=.<sfx>]
		   [--ignore-if-in-upstream] [--always]
		   [--cover-from-description=<mode>]
		   [--rfc[=<rfc>]] [--subject-prefix=<subject-prefix>]
		   [(--reroll-count|-v) <n>]
		   [--to=<email>] [--cc=<email>]
		   [--[no-]cover-letter] [--quiet]
		   [--[no-]encode-email-headers]
		   [--no-notes | --notes[=<ref>]]
		   [--interdiff=<previous>]
		   [--range-diff=<previous> [--creation-factor=<percent>]]
		   [--filename-max-length=<n>]
		   [--progress]
		   [<common-diff-options>]
		   [ <since> | <revision-range> ]

DESCRIPTION
-----------

Prepare each non-merge commit with its "patch" in
one "message" per commit, formatted to resemble a UNIX mailbox.
The output of this command is convenient for e-mail submission or
for use with 'git am'.

A "message" generated by the command consists of three parts:

* A brief metadata header that begins with `From <commit>`
  with a fixed `Mon Sep 17 00:00:00 2001` datestamp to help programs
  like "file(1)" to recognize that the file is an output from this
  command, fields that record the author identity, the author date,
  and the title of the change (taken from the first paragraph of the
  commit log message).

* The second and subsequent paragraphs of the commit log message.

* The "patch", which is the "diff -p --stat" output (see
  linkgit:git-diff[1]) between the commit and its parent.

The log message and the patch are separated by a line with a
three-dash line.

There are two ways to specify which commits to operate on.

1. A single commit, <since>, specifies that the commits leading
   to the tip of the current branch that are not in the history
   that leads to the <since> to be output.

2. Generic <revision-range> expression (see "SPECIFYING
   REVISIONS" section in linkgit:gitrevisions[7]) means the
   commits in the specified range.

The first rule takes precedence in the case of a single <commit>.  To
apply the second rule, i.e., format everything since the beginning of
history up until <commit>, use the `--root` option: `git format-patch
--root <commit>`.  If you want to format only <commit> itself, you
can do this with `git format-patch -1 <commit>`.

By default, each output file is numbered sequentially from 1, and uses the
first line of the commit message (massaged for pathname safety) as
the filename. With the `--numbered-files` option, the output file names
will only be numbers, without the first line of the commit appended.
The names of the output files are printed to standard
output, unless the `--stdout` option is specified.

If `-o` is specified, output files are created in <dir>.  Otherwise
they are created in the current working directory. The default path
can be set with the `format.outputDirectory` configuration option.
The `-o` option takes precedence over `format.outputDirectory`.
To store patches in the current working directory even when
`format.outputDirectory` points elsewhere, use `-o .`. All directory
components will be created.

By default, the subject of a single patch is "[PATCH] " followed by
the concatenation of lines from the commit message up to the first blank
line (see the DISCUSSION section of linkgit:git-commit[1]).

When multiple patches are output, the subject prefix will instead be
"[PATCH n/m] ".  To force 1/1 to be added for a single patch, use `-n`.
To omit patch numbers from the subject, use `-N`.

If given `--thread`, `git-format-patch` will generate `In-Reply-To` and
`References` headers to make the second and

Title: Git Format Patch Command
Summary
The git-format-patch command prepares patches for e-mail submission, generating a formatted message for each non-merge commit with its corresponding patch, and is convenient for use with 'git am' or e-mail submission.