Documentation / git-revert.txton commit Merge branch 'sg/rebase-progress' (6624e07)
   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[<keyid>]] <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-restore[1], specifically the `--source`
  30option. Take care with these alternatives as
  31both will discard uncommitted changes in your working directory.
  32
  33See "Reset, restore and revert" in linkgit:git[1] for the differences
  34between the three commands.
  35
  36OPTIONS
  37-------
  38<commit>...::
  39        Commits to revert.
  40        For a more complete list of ways to spell commit names, see
  41        linkgit:gitrevisions[7].
  42        Sets of commits can also be given but no traversal is done by
  43        default, see linkgit:git-rev-list[1] and its `--no-walk`
  44        option.
  45
  46-e::
  47--edit::
  48        With this option, 'git revert' will let you edit the commit
  49        message prior to committing the revert. This is the default if
  50        you run the command from a terminal.
  51
  52-m parent-number::
  53--mainline parent-number::
  54        Usually you cannot revert a merge because you do not know which
  55        side of the merge should be considered the mainline.  This
  56        option specifies the parent number (starting from 1) of
  57        the mainline and allows revert to reverse the change
  58        relative to the specified parent.
  59+
  60Reverting a merge commit declares that you will never want the tree changes
  61brought in by the merge.  As a result, later merges will only bring in tree
  62changes introduced by commits that are not ancestors of the previously
  63reverted merge.  This may or may not be what you want.
  64+
  65See the link:howto/revert-a-faulty-merge.html[revert-a-faulty-merge How-To] for
  66more details.
  67
  68--no-edit::
  69        With this option, 'git revert' will not start the commit
  70        message editor.
  71
  72--cleanup=<mode>::
  73        This option determines how the commit message will be cleaned up before
  74        being passed on to the commit machinery. See linkgit:git-commit[1] for more
  75        details. In particular, if the '<mode>' is given a value of `scissors`,
  76        scissors will be appended to `MERGE_MSG` before being passed on in the case
  77        of a conflict.
  78
  79-n::
  80--no-commit::
  81        Usually the command automatically creates some commits with
  82        commit log messages stating which commits were
  83        reverted.  This flag applies the changes necessary
  84        to revert the named commits to your working tree
  85        and the index, but does not make the commits.  In addition,
  86        when this option is used, your index does not have to match
  87        the HEAD commit.  The revert is done against the
  88        beginning state of your index.
  89+
  90This is useful when reverting more than one commits'
  91effect to your index in a row.
  92
  93-S[<keyid>]::
  94--gpg-sign[=<keyid>]::
  95        GPG-sign commits. The `keyid` argument is optional and
  96        defaults to the committer identity; if specified, it must be
  97        stuck to the option without a space.
  98
  99-s::
 100--signoff::
 101        Add Signed-off-by line at the end of the commit message.
 102        See the signoff option in linkgit:git-commit[1] for more information.
 103
 104--strategy=<strategy>::
 105        Use the given merge strategy.  Should only be used once.
 106        See the MERGE STRATEGIES section in linkgit:git-merge[1]
 107        for details.
 108
 109-X<option>::
 110--strategy-option=<option>::
 111        Pass the merge strategy-specific option through to the
 112        merge strategy.  See linkgit:git-merge[1] for details.
 113
 114--rerere-autoupdate::
 115--no-rerere-autoupdate::
 116        Allow the rerere mechanism to update the index with the
 117        result of auto-conflict resolution if possible.
 118
 119SEQUENCER SUBCOMMANDS
 120---------------------
 121include::sequencer.txt[]
 122
 123EXAMPLES
 124--------
 125`git revert HEAD~3`::
 126
 127        Revert the changes specified by the fourth last commit in HEAD
 128        and create a new commit with the reverted changes.
 129
 130`git revert -n master~5..master~2`::
 131
 132        Revert the changes done by commits from the fifth last commit
 133        in master (included) to the third last commit in master
 134        (included), but do not create any commit with the reverted
 135        changes. The revert only modifies the working tree and the
 136        index.
 137
 138SEE ALSO
 139--------
 140linkgit:git-cherry-pick[1]
 141
 142GIT
 143---
 144Part of the linkgit:git[1] suite