<?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-merge-index(1)">
<articleinfo>
    <title>git-merge-index(1)</title>
        <indexterm>
                <primary>git-merge-index(1)</primary>
        </indexterm>
</articleinfo>
<simplesect id="_name">
<title>NAME</title>
<simpara>git-merge-index - Run a merge for files needing merging</simpara>
</simplesect>
<simplesect id="_synopsis">
<title>SYNOPSIS</title>
<simpara><emphasis>git merge-index</emphasis> [-o] [-q] &lt;merge-program&gt; (-a | [--] &lt;file&gt;\*)</simpara>
</simplesect>
<simplesect id="_description">
<title>DESCRIPTION</title>
<simpara>This looks up the &lt;file&gt;(s) in the index and, if there are any merge
entries, passes the SHA1 hash for those files as arguments 1, 2, 3 (empty
argument if no file), and &lt;file&gt; as argument 4.  File modes for the three
files are passed as arguments 5, 6 and 7.</simpara>
</simplesect>
<simplesect id="_options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>
--
</term>
<listitem>
<simpara>
        Do not interpret any more arguments as options.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-a
</term>
<listitem>
<simpara>
        Run merge against all files in the index that need merging.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-o
</term>
<listitem>
<simpara>
        Instead of stopping at the first failed merge, do all of them
        in one shot - continue with merging even when previous merges
        returned errors, and only return the error code after all the
        merges.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-q
</term>
<listitem>
<simpara>
        Do not complain about a failed merge program (a merge program
        failure usually indicates conflicts during the merge). This is for
        porcelains which might want to emit custom messages.
</simpara>
</listitem>
</varlistentry>
</variablelist>
<simpara>If <emphasis>git-merge-index</emphasis> is called with multiple &lt;file&gt;s (or -a) then it
processes them in turn only stopping if merge returns a non-zero exit
code.</simpara>
<simpara>Typically this is run with a script calling git&#8217;s imitation of
the <emphasis>merge</emphasis> command from the RCS package.</simpara>
<simpara>A sample script called <emphasis>git-merge-one-file</emphasis> is included in the
distribution.</simpara>
<simpara>ALERT ALERT ALERT! The git "merge object order" is different from the
RCS <emphasis>merge</emphasis> program merge object order. In the above ordering, the
original is first. But the argument order to the 3-way merge program
<emphasis>merge</emphasis> is to have the original in the middle. Don&#8217;t ask me why.</simpara>
<simpara>Examples:</simpara>
<literallayout class="monospaced">torvalds@ppc970:~/merge-test&gt; git merge-index cat MM
This is MM from the original tree.                    # original
This is modified MM in the branch A.                  # merge1
This is modified MM in the branch B.                  # merge2
This is modified MM in the branch B.                  # current contents</literallayout>
<simpara>or</simpara>
<literallayout class="monospaced">torvalds@ppc970:~/merge-test&gt; git merge-index cat AA MM
cat: : No such file or directory
This is added AA in the branch A.
This is added AA in the branch B.
This is added AA in the branch B.
fatal: merge program failed</literallayout>
<simpara>where the latter example shows how <emphasis>git-merge-index</emphasis> will stop trying to
merge once anything has returned an error (i.e., <literal>cat</literal> returned an error
for the AA file, because it didn&#8217;t exist in the original, and thus
<emphasis>git-merge-index</emphasis> didn&#8217;t even try to merge the MM thing).</simpara>
</simplesect>
<simplesect id="_author">
<title>Author</title>
<simpara>Written by Linus Torvalds &lt;<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>&gt;
One-shot merge by Petr Baudis &lt;<ulink url="mailto:pasky@ucw.cz">pasky@ucw.cz</ulink>&gt;</simpara>
</simplesect>
<simplesect id="_documentation">
<title>Documentation</title>
<simpara>Documentation by David Greaves, 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>
