]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-revert.txt
Merge branch 'rs/use-xstrncmpz'
[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]
d1ddc4e3 11'git revert' [--[no-]edit] [-n] [-m <parent-number>] [-s] [-S[<keyid>]] <commit>...
de81ca3f 12'git revert' (--continue | --skip | --abort | --quit)
7fc9d69f
JH
13
14DESCRIPTION
15-----------
7fc9d69f 16
86c7bb47
CC
17Given one or more existing commits, revert the changes that the
18related patches introduce, and record some new commits that record
19them. This requires your working tree to be clean (no modifications
20from the HEAD commit).
21
22Note: 'git revert' is used to record some new commits to reverse the
23effect of some earlier commits (often only a faulty one). If you want to
3a634dcf 24throw away all uncommitted changes in your working directory, you
bcf9626a 25should see linkgit:git-reset[1], particularly the `--hard` option. If
3a634dcf 26you want to extract specific files as they were in another commit, you
80f537f7
NTND
27should see linkgit:git-restore[1], specifically the `--source`
28option. Take care with these alternatives as
3a634dcf
TC
29both will discard uncommitted changes in your working directory.
30
46e91b66
NTND
31See "Reset, restore and revert" in linkgit:git[1] for the differences
32between the three commands.
33
7fc9d69f
JH
34OPTIONS
35-------
86c7bb47
CC
36<commit>...::
37 Commits to revert.
41a5564e 38 For a more complete list of ways to spell commit names, see
9d83e382 39 linkgit:gitrevisions[7].
86c7bb47 40 Sets of commits can also be given but no traversal is done by
bcf9626a 41 default, see linkgit:git-rev-list[1] and its `--no-walk`
86c7bb47 42 option.
7fc9d69f 43
3240240f
SB
44-e::
45--edit::
0b444cdb 46 With this option, 'git revert' will let you edit the commit
233808db 47 message prior to committing the revert. This is the default if
8bf14d6e
PB
48 you run the command from a terminal.
49
3240240f
SB
50-m parent-number::
51--mainline parent-number::
7791ecbc
JH
52 Usually you cannot revert a merge because you do not know which
53 side of the merge should be considered the mainline. This
54 option specifies the parent number (starting from 1) of
55 the mainline and allows revert to reverse the change
56 relative to the specified parent.
b80b5d67
BSSJ
57+
58Reverting a merge commit declares that you will never want the tree changes
59brought in by the merge. As a result, later merges will only bring in tree
60changes introduced by commits that are not ancestors of the previously
61reverted merge. This may or may not be what you want.
62+
d5ff3b4b 63See the link:howto/revert-a-faulty-merge.html[revert-a-faulty-merge How-To] for
b80b5d67 64more details.
7791ecbc 65
8bf14d6e 66--no-edit::
0b444cdb 67 With this option, 'git revert' will not start the commit
8bf14d6e
PB
68 message editor.
69
1a2b985f
DL
70--cleanup=<mode>::
71 This option determines how the commit message will be cleaned up before
72 being passed on to the commit machinery. See linkgit:git-commit[1] for more
73 details. In particular, if the '<mode>' is given a value of `scissors`,
74 scissors will be appended to `MERGE_MSG` before being passed on in the case
75 of a conflict.
76
3240240f
SB
77-n::
78--no-commit::
86c7bb47
CC
79 Usually the command automatically creates some commits with
80 commit log messages stating which commits were
81 reverted. This flag applies the changes necessary
82 to revert the named commits to your working tree
83 and the index, but does not make the commits. In addition,
8bd867ee
PB
84 when this option is used, your index does not have to match
85 the HEAD commit. The revert is done against the
86 beginning state of your index.
df8baa42
JF
87+
88This is useful when reverting more than one commits'
8bd867ee 89effect to your index in a row.
de2b82c6 90
340f2c5e
MM
91-S[<keyid>]::
92--gpg-sign[=<keyid>]::
cf0ad4d1 93--no-gpg-sign::
2b594bf9
MM
94 GPG-sign commits. The `keyid` argument is optional and
95 defaults to the committer identity; if specified, it must be
cf0ad4d1
ĐTCD
96 stuck to the option without a space. `--no-gpg-sign` is useful to
97 countermand both `commit.gpgSign` configuration variable, and
98 earlier `--gpg-sign`.
3253553e 99
3240240f
SB
100-s::
101--signoff::
3abd4a67 102 Add a `Signed-off-by` trailer at the end of the commit message.
b2c150d3 103 See the signoff option in linkgit:git-commit[1] for more information.
cfd9c277 104
67ac1e1d
JN
105--strategy=<strategy>::
106 Use the given merge strategy. Should only be used once.
107 See the MERGE STRATEGIES section in linkgit:git-merge[1]
108 for details.
109
110-X<option>::
111--strategy-option=<option>::
112 Pass the merge strategy-specific option through to the
113 merge strategy. See linkgit:git-merge[1] for details.
114
0dbc715a 115include::rerere-options.txt[]
aba4954c 116
43966ab3
JH
117--reference::
118 Instead of starting the body of the log message with "This
2162f9f6 119 reverts <full-object-name-of-the-commit-being-reverted>.",
43966ab3
JH
120 refer to the commit using "--pretty=reference" format
121 (cf. linkgit:git-log[1]). The `revert.reference`
122 configuration variable can be used to enable this option by
123 default.
124
125
26ae337b
RR
126SEQUENCER SUBCOMMANDS
127---------------------
128include::sequencer.txt[]
129
86c7bb47
CC
130EXAMPLES
131--------
5d2fc913 132`git revert HEAD~3`::
86c7bb47
CC
133
134 Revert the changes specified by the fourth last commit in HEAD
135 and create a new commit with the reverted changes.
136
6cf378f0 137`git revert -n master~5..master~2`::
86c7bb47
CC
138
139 Revert the changes done by commits from the fifth last commit
140 in master (included) to the third last commit in master
141 (included), but do not create any commit with the reverted
142 changes. The revert only modifies the working tree and the
143 index.
de2b82c6 144
c9192f9e
OB
145DISCUSSION
146----------
147
148While git creates a basic commit message automatically, it is
149_strongly_ recommended to explain why the original commit is being
150reverted.
151In addition, repeatedly reverting reverts will result in increasingly
2162f9f6 152unwieldy subject lines, for example 'Reapply "Reapply "<original-subject>""'.
c9192f9e
OB
153Please consider rewording these to be shorter and more unique.
154
16f6b0d1
ÆAB
155CONFIGURATION
156-------------
157
158include::includes/cmd-config-section-all.txt[]
159
160include::config/revert.txt[]
161
86c7bb47
CC
162SEE ALSO
163--------
164linkgit:git-cherry-pick[1]
165
7fc9d69f
JH
166GIT
167---
9e1f0a85 168Part of the linkgit:git[1] suite