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