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