Documentation / git-revert.txton commit test-lib: redirect stdin of tests (781f76b)
   1git-revert(1)
   2=============
   3
   4NAME
   5----
   6git-revert - Revert some existing commits
   7
   8SYNOPSIS
   9--------
  10[verse]
  11'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>...
  12
  13DESCRIPTION
  14-----------
  15
  16Given one or more existing commits, revert the changes that the
  17related patches introduce, and record some new commits that record
  18them.  This requires your working tree to be clean (no modifications
  19from the HEAD commit).
  20
  21Note: 'git revert' is used to record some new commits to reverse the
  22effect of some earlier commits (often only a faulty one).  If you want to
  23throw away all uncommitted changes in your working directory, you
  24should see linkgit:git-reset[1], particularly the '--hard' option.  If
  25you want to extract specific files as they were in another commit, you
  26should see linkgit:git-checkout[1], specifically the `git checkout
  27<commit> \-- <filename>` syntax.  Take care with these alternatives as
  28both will discard uncommitted changes in your working directory.
  29
  30OPTIONS
  31-------
  32<commit>...::
  33        Commits to revert.
  34        For a more complete list of ways to spell commit names, see
  35        linkgit:gitrevisions[7].
  36        Sets of commits can also be given but no traversal is done by
  37        default, see linkgit:git-rev-list[1] and its '--no-walk'
  38        option.
  39
  40-e::
  41--edit::
  42        With this option, 'git revert' will let you edit the commit
  43        message prior to committing the revert. This is the default if
  44        you run the command from a terminal.
  45
  46-m parent-number::
  47--mainline parent-number::
  48        Usually you cannot revert a merge because you do not know which
  49        side of the merge should be considered the mainline.  This
  50        option specifies the parent number (starting from 1) of
  51        the mainline and allows revert to reverse the change
  52        relative to the specified parent.
  53+
  54Reverting a merge commit declares that you will never want the tree changes
  55brought in by the merge.  As a result, later merges will only bring in tree
  56changes introduced by commits that are not ancestors of the previously
  57reverted merge.  This may or may not be what you want.
  58+
  59See the link:howto/revert-a-faulty-merge.txt[revert-a-faulty-merge How-To] for
  60more details.
  61
  62--no-edit::
  63        With this option, 'git revert' will not start the commit
  64        message editor.
  65
  66-n::
  67--no-commit::
  68        Usually the command automatically creates some commits with
  69        commit log messages stating which commits were
  70        reverted.  This flag applies the changes necessary
  71        to revert the named commits to your working tree
  72        and the index, but does not make the commits.  In addition,
  73        when this option is used, your index does not have to match
  74        the HEAD commit.  The revert is done against the
  75        beginning state of your index.
  76+
  77This is useful when reverting more than one commits'
  78effect to your index in a row.
  79
  80-s::
  81--signoff::
  82        Add Signed-off-by line at the end of the commit message.
  83
  84--strategy=<strategy>::
  85        Use the given merge strategy.  Should only be used once.
  86        See the MERGE STRATEGIES section in linkgit:git-merge[1]
  87        for details.
  88
  89-X<option>::
  90--strategy-option=<option>::
  91        Pass the merge strategy-specific option through to the
  92        merge strategy.  See linkgit:git-merge[1] for details.
  93
  94EXAMPLES
  95--------
  96`git revert HEAD~3`::
  97
  98        Revert the changes specified by the fourth last commit in HEAD
  99        and create a new commit with the reverted changes.
 100
 101`git revert -n master{tilde}5..master{tilde}2`::
 102
 103        Revert the changes done by commits from the fifth last commit
 104        in master (included) to the third last commit in master
 105        (included), but do not create any commit with the reverted
 106        changes. The revert only modifies the working tree and the
 107        index.
 108
 109SEE ALSO
 110--------
 111linkgit:git-cherry-pick[1]
 112
 113GIT
 114---
 115Part of the linkgit:git[1] suite