<?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-revert(1)">
<articleinfo>
    <title>git-revert(1)</title>
        <indexterm>
                <primary>git-revert(1)</primary>
        </indexterm>
</articleinfo>
<simplesect id="_name">
<title>NAME</title>
<simpara>git-revert - Revert an existing commit</simpara>
</simplesect>
<simplesect id="_synopsis">
<title>SYNOPSIS</title>
<simpara><emphasis>git revert</emphasis> [--edit | --no-edit] [-n] [-m parent-number] [-s] &lt;commit&gt;</simpara>
</simplesect>
<simplesect id="_description">
<title>DESCRIPTION</title>
<simpara>Given one existing commit, revert the change the patch introduces, and record a
new commit that records it.  This requires your working tree to be clean (no
modifications from the HEAD commit).</simpara>
<simpara>Note: <emphasis>git revert</emphasis> is used to record a new commit to reverse the
effect of an earlier commit (often a faulty one).  If you want to
throw away all uncommitted changes in your working directory, you
should see <xref linkend="git-reset(1)"/>, particularly the <emphasis>--hard</emphasis> option.  If
you want to extract specific files as they were in another commit, you
should see <xref linkend="git-checkout(1)"/>, specifically the <emphasis>git checkout
&lt;commit&gt;&#8201;&#8212;&#8201;&lt;filename&gt;</emphasis> syntax.  Take care with these alternatives as
both will discard uncommitted changes in your working directory.</simpara>
</simplesect>
<simplesect id="_options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>
&lt;commit&gt;
</term>
<listitem>
<simpara>
        Commit to revert.
        For a more complete list of ways to spell commit names, see
        "SPECIFYING REVISIONS" section in <xref linkend="git-rev-parse(1)"/>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-e
</term>
<term>
--edit
</term>
<listitem>
<simpara>
        With this option, <emphasis>git-revert</emphasis> will let you edit the commit
        message prior to committing the revert. This is the default if
        you run the command from a terminal.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-m parent-number
</term>
<term>
--mainline parent-number
</term>
<listitem>
<simpara>
        Usually you cannot revert a merge because you do not know which
        side of the merge should be considered the mainline.  This
        option specifies the parent number (starting from 1) of
        the mainline and allows revert to reverse the change
        relative to the specified parent.
</simpara>
<simpara>Reverting a merge commit declares that you will never want the tree changes
brought in by the merge.  As a result, later merges will only bring in tree
changes introduced by commits that are not ancestors of the previously
reverted merge.  This may or may not be what you want.</simpara>
<simpara>See the <ulink url="howto/revert-a-faulty-merge.txt">revert-a-faulty-merge How-To</ulink> for
more details.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--no-edit
</term>
<listitem>
<simpara>
        With this option, <emphasis>git-revert</emphasis> will not start the commit
        message editor.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-n
</term>
<term>
--no-commit
</term>
<listitem>
<simpara>
        Usually the command automatically creates a commit with
        a commit log message stating which commit was
        reverted.  This flag applies the change necessary
        to revert the named commit to your working tree
        and the index, but does not make the commit.  In addition,
        when this option is used, your index does not have to match
        the HEAD commit.  The revert is done against the
        beginning state of your index.
</simpara>
<simpara>This is useful when reverting more than one commits'
effect to your index in a row.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
-s
</term>
<term>
--signoff
</term>
<listitem>
<simpara>
        Add Signed-off-by line at the end of the commit message.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</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 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>
