<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<article lang="en" id="git-am(1)">
<articleinfo>
    <title>git-am(1)</title>
        <indexterm>
                <primary>git-am(1)</primary>
        </indexterm>
</articleinfo>
<simplesect id="_name">
<title>NAME</title>
<simpara>git-am - Apply a series of patches from a mailbox</simpara>
</simplesect>
<simplesect id="_synopsis">
<title>SYNOPSIS</title>
<blockquote>
<literallayout><emphasis>git am</emphasis> [--signoff] [--keep] [--utf8 | --no-utf8]
         [--3way] [--interactive] [--committer-date-is-author-date]
         [--ignore-date]
         [--whitespace=&lt;option&gt;] [-C&lt;n&gt;] [-p&lt;n&gt;] [--directory=&lt;dir&gt;]
         [--reject]
         [&lt;mbox&gt; | &lt;Maildir&gt;&#8230;]
<emphasis>git am</emphasis> (--skip | --resolved | --abort)</literallayout>
</blockquote>
</simplesect>
<simplesect id="_description">
<title>DESCRIPTION</title>
<simpara>Splits mail messages in a mailbox into commit log message,
authorship information and patches, and applies them to the
current branch.</simpara>
</simplesect>
<simplesect id="_options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>
&lt;mbox&gt;|&lt;Maildir&gt;&#8230;
</term>
<listitem>
<simpara>
        The list of mailbox files to read patches from. If you do not
        supply this argument, reads from the standard input. If you supply
        directories, they&#8217;ll be treated as Maildirs.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-s
</term>
<term>
--signoff
</term>
<listitem>
<simpara>
        Add <literal>Signed-off-by:</literal> line to the commit message, using
        the committer identity of yourself.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-k
</term>
<term>
--keep
</term>
<listitem>
<simpara>
        Pass <literal>-k</literal> flag to <emphasis>git-mailinfo</emphasis> (see <xref linkend="git-mailinfo(1)"/>).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-u
</term>
<term>
--utf8
</term>
<listitem>
<simpara>
        Pass <literal>-u</literal> flag to <emphasis>git-mailinfo</emphasis> (see <xref linkend="git-mailinfo(1)"/>).
        The proposed commit log message taken from the e-mail
        is re-coded into UTF-8 encoding (configuration variable
        <literal>i18n.commitencoding</literal> can be used to specify project&#8217;s
        preferred encoding if it is not UTF-8).
</simpara>
<simpara>This was optional in prior versions of git, but now it is the
default.   You could use <literal>--no-utf8</literal> to override this.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--no-utf8
</term>
<listitem>
<simpara>
        Pass <literal>-n</literal> flag to <emphasis>git-mailinfo</emphasis> (see
        <xref linkend="git-mailinfo(1)"/>).
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-3
</term>
<term>
--3way
</term>
<listitem>
<simpara>
        When the patch does not apply cleanly, fall back on
        3-way merge, if the patch records the identity of blobs
        it is supposed to apply to, and we have those blobs
        available locally.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--whitespace=&lt;option&gt;
</term>
<term>
-C&lt;n&gt;
</term>
<term>
-p&lt;n&gt;
</term>
<term>
--directory=&lt;dir&gt;
</term>
<term>
--reject
</term>
<listitem>
<simpara>
        These flags are passed to the <emphasis>git-apply</emphasis> (see <xref linkend="git-apply(1)"/>)
        program that applies
        the patch.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-i
</term>
<term>
--interactive
</term>
<listitem>
<simpara>
        Run interactively.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--committer-date-is-author-date
</term>
<listitem>
<simpara>
        By default the command records the date from the e-mail
        message as the commit author date, and uses the time of
        commit creation as the committer date. This allows the
        user to lie about the committer date by using the same
        timestamp as the author date.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--ignore-date
</term>
<listitem>
<simpara>
        By default the command records the date from the e-mail
        message as the commit author date, and uses the time of
        commit creation as the committer date. This allows the
        user to lie about author timestamp by using the same
        timestamp as the committer date.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--skip
</term>
<listitem>
<simpara>
        Skip the current patch.  This is only meaningful when
        restarting an aborted patch.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-r
</term>
<term>
--resolved
</term>
<listitem>
<simpara>
        After a patch failure (e.g. attempting to apply
        conflicting patch), the user has applied it by hand and
        the index file stores the result of the application.
        Make a commit using the authorship and commit log
        extracted from the e-mail message and the current index
        file, and continue.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--resolvemsg=&lt;msg&gt;
</term>
<listitem>
<simpara>
        When a patch failure occurs, &lt;msg&gt; will be printed
        to the screen before exiting.  This overrides the
        standard message informing you to use <literal>--resolved</literal>
        or <literal>--skip</literal> to handle the failure.  This is solely
        for internal use between <emphasis>git-rebase</emphasis> and <emphasis>git-am</emphasis>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--abort
</term>
<listitem>
<simpara>
        Restore the original branch and abort the patching operation.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_discussion">
<title>DISCUSSION</title>
<simpara>The commit author name is taken from the "From: " line of the
message, and commit author time is taken from the "Date: " line
of the message.  The "Subject: " line is used as the title of
the commit, after stripping common prefix "[PATCH &lt;anything&gt;]".
It is supposed to describe what the commit is about concisely as
a one line text.</simpara>
<simpara>The body of the message (iow, after a blank line that terminates
RFC2822 headers) can begin with "Subject: " and "From: " lines
that are different from those of the mail header, to override
the values of these fields.</simpara>
<simpara>The commit message is formed by the title taken from the
"Subject: ", a blank line and the body of the message up to
where the patch begins.  Excess whitespaces at the end of the
lines are automatically stripped.</simpara>
<simpara>The patch is expected to be inline, directly following the
message.  Any line that is of form:</simpara>
<itemizedlist>
<listitem>
<simpara>
three-dashes and end-of-line, or
</simpara>
</listitem>
<listitem>
<simpara>
a line that begins with "diff -", or
</simpara>
</listitem>
<listitem>
<simpara>
a line that begins with "Index: "
</simpara>
</listitem>
</itemizedlist>
<simpara>is taken as the beginning of a patch, and the commit log message
is terminated before the first occurrence of such a line.</simpara>
<simpara>When initially invoking it, you give it names of the mailboxes
to crunch.  Upon seeing the first patch that does not apply, it
aborts in the middle,.  You can recover from this in one of two ways:</simpara>
<orderedlist numeration="arabic">
<listitem>
<simpara>
skip the current patch by re-running the command with <emphasis>--skip</emphasis>
  option.
</simpara>
</listitem>
<listitem>
<simpara>
hand resolve the conflict in the working directory, and update
  the index file to bring it in a state that the patch should
  have produced.  Then run the command with <emphasis>--resolved</emphasis> option.
</simpara>
</listitem>
</orderedlist>
<simpara>The command refuses to process new mailboxes while <literal>.git/rebase-apply</literal>
directory exists, so if you decide to start over from scratch,
run <literal>rm -f -r .git/rebase-apply</literal> before running the command with mailbox
names.</simpara>
<simpara>Before any patches are applied, ORIG_HEAD is set to the tip of the
current branch.  This is useful if you have problems with multiple
commits, like running <emphasis>git am</emphasis> on the wrong branch or an error in the
commits that is more easily fixed by changing the mailbox (e.g.
errors in the "From:" lines).</simpara>
</simplesect>
<simplesect id="_see_also">
<title>SEE ALSO</title>
<simpara><xref linkend="git-apply(1)"/>.</simpara>
</simplesect>
<simplesect id="_author">
<title>Author</title>
<simpara>Written by Junio C Hamano &lt;<ulink url="mailto:gitster@pobox.com">gitster@pobox.com</ulink>&gt;</simpara>
</simplesect>
<simplesect id="_documentation">
<title>Documentation</title>
<simpara>Documentation by Petr Baudis, Junio C Hamano and the git-list &lt;<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>&gt;.</simpara>
</simplesect>
<simplesect id="_git">
<title>GIT</title>
<simpara>Part of the <xref linkend="git(1)"/> suite</simpara>
</simplesect>
</article>
