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