]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-revert.txt
doc: typo: s/can not/cannot/ and s/is does/does/
[thirdparty/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--------
7791a1d9 10[verse]
340f2c5e 11'git revert' [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>...
5a5d80f4 12'git revert' --continue
f80a8726 13'git revert' --quit
539047c1 14'git revert' --abort
7fc9d69f
JH
15
16DESCRIPTION
17-----------
7fc9d69f 18
86c7bb47
CC
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
3a634dcf 26throw away all uncommitted changes in your working directory, you
bcf9626a 27should see linkgit:git-reset[1], particularly the `--hard` option. If
3a634dcf 28you want to extract specific files as they were in another commit, you
ca768288 29should see linkgit:git-checkout[1], specifically the `git checkout
6cf378f0 30<commit> -- <filename>` syntax. Take care with these alternatives as
3a634dcf
TC
31both will discard uncommitted changes in your working directory.
32
7fc9d69f
JH
33OPTIONS
34-------
86c7bb47
CC
35<commit>...::
36 Commits to revert.
41a5564e 37 For a more complete list of ways to spell commit names, see
9d83e382 38 linkgit:gitrevisions[7].
86c7bb47 39 Sets of commits can also be given but no traversal is done by
bcf9626a 40 default, see linkgit:git-rev-list[1] and its `--no-walk`
86c7bb47 41 option.
7fc9d69f 42
3240240f
SB
43-e::
44--edit::
0b444cdb 45 With this option, 'git revert' will let you edit the commit
233808db 46 message prior to committing the revert. This is the default if
8bf14d6e
PB
47 you run the command from a terminal.
48
3240240f
SB
49-m parent-number::
50--mainline parent-number::
7791ecbc
JH
51 Usually you cannot revert a merge because you do not know which
52 side of the merge should be considered the mainline. This
53 option specifies the parent number (starting from 1) of
54 the mainline and allows revert to reverse the change
55 relative to the specified parent.
b80b5d67
BSSJ
56+
57Reverting a merge commit declares that you will never want the tree changes
58brought in by the merge. As a result, later merges will only bring in tree
59changes introduced by commits that are not ancestors of the previously
60reverted merge. This may or may not be what you want.
61+
d5ff3b4b 62See the link:howto/revert-a-faulty-merge.html[revert-a-faulty-merge How-To] for
b80b5d67 63more details.
7791ecbc 64
8bf14d6e 65--no-edit::
0b444cdb 66 With this option, 'git revert' will not start the commit
8bf14d6e
PB
67 message editor.
68
1a2b985f
DL
69--cleanup=<mode>::
70 This option determines how the commit message will be cleaned up before
71 being passed on to the commit machinery. See linkgit:git-commit[1] for more
72 details. In particular, if the '<mode>' is given a value of `scissors`,
73 scissors will be appended to `MERGE_MSG` before being passed on in the case
74 of a conflict.
75
3240240f
SB
76-n::
77--no-commit::
86c7bb47
CC
78 Usually the command automatically creates some commits with
79 commit log messages stating which commits were
80 reverted. This flag applies the changes necessary
81 to revert the named commits to your working tree
82 and the index, but does not make the commits. In addition,
8bd867ee
PB
83 when this option is used, your index does not have to match
84 the HEAD commit. The revert is done against the
85 beginning state of your index.
df8baa42
JF
86+
87This is useful when reverting more than one commits'
8bd867ee 88effect to your index in a row.
de2b82c6 89
340f2c5e
MM
90-S[<keyid>]::
91--gpg-sign[=<keyid>]::
2b594bf9
MM
92 GPG-sign commits. The `keyid` argument is optional and
93 defaults to the committer identity; if specified, it must be
94 stuck to the option without a space.
3253553e 95
3240240f
SB
96-s::
97--signoff::
cfd9c277 98 Add Signed-off-by line at the end of the commit message.
b2c150d3 99 See the signoff option in linkgit:git-commit[1] for more information.
cfd9c277 100
67ac1e1d
JN
101--strategy=<strategy>::
102 Use the given merge strategy. Should only be used once.
103 See the MERGE STRATEGIES section in linkgit:git-merge[1]
104 for details.
105
106-X<option>::
107--strategy-option=<option>::
108 Pass the merge strategy-specific option through to the
109 merge strategy. See linkgit:git-merge[1] for details.
110
aba4954c
PW
111--rerere-autoupdate::
112--no-rerere-autoupdate::
113 Allow the rerere mechanism to update the index with the
114 result of auto-conflict resolution if possible.
115
26ae337b
RR
116SEQUENCER SUBCOMMANDS
117---------------------
118include::sequencer.txt[]
119
86c7bb47
CC
120EXAMPLES
121--------
5d2fc913 122`git revert HEAD~3`::
86c7bb47
CC
123
124 Revert the changes specified by the fourth last commit in HEAD
125 and create a new commit with the reverted changes.
126
6cf378f0 127`git revert -n master~5..master~2`::
86c7bb47
CC
128
129 Revert the changes done by commits from the fifth last commit
130 in master (included) to the third last commit in master
131 (included), but do not create any commit with the reverted
132 changes. The revert only modifies the working tree and the
133 index.
de2b82c6 134
86c7bb47
CC
135SEE ALSO
136--------
137linkgit:git-cherry-pick[1]
138
7fc9d69f
JH
139GIT
140---
9e1f0a85 141Part of the linkgit:git[1] suite