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