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