interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / Documentation / git-revert.adoc

173 lines · 5611 bytes Raw Blame History
1git-revert(1)
2=============
3
4NAME
5----
6git-revert - Revert some existing commits
7
8SYNOPSIS
9--------
10[verse]
11'git revert' [--[no-]edit] [-n] [-m <parent-number>] [-s] [-S[<keyid>]] <commit>...
12'git revert' (--continue | --skip | --abort | --quit)
13
14DESCRIPTION
15-----------
16
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
24throw away all uncommitted changes in your working directory, you
25should see linkgit:git-reset[1], particularly the `--hard` option. If
26you want to extract specific files as they were in another commit, you
27should see linkgit:git-restore[1], specifically the `--source`
28option. Take care with these alternatives as
29both will discard uncommitted changes in your working directory.
30
31See "Reset, restore and revert" in linkgit:git[1] for the differences
32between the three commands.
33
34Reverting a commit may result in a merge conflict.
35See linkgit:gitmergeconflicts[7] (or `git help mergeconflicts`)
36for a guide to handling merge conflicts.
37
38OPTIONS
39-------
40<commit>...::
41 Commits to revert.
42 For a more complete list of ways to spell commit names, see
43 linkgit:gitrevisions[7].
44 Sets of commits can also be given but no traversal is done by
45 default, see linkgit:git-rev-list[1] and its `--no-walk`
46 option.
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+
62Reverting a merge commit declares that you will never want the tree changes
63brought in by the merge. As a result, later merges will only bring in tree
64changes introduced by commits that are not ancestors of the previously
65reverted merge. This may or may not be what you want.
66+
67See the link:howto/revert-a-faulty-merge.html[revert-a-faulty-merge How-To] for
68more details.
69
70--no-edit::
71 With this option, 'git revert' will not start the commit
72 message editor.
73
74--cleanup=<mode>::
75 This option determines how the commit message will be cleaned up before
76 being passed on to the commit machinery. See linkgit:git-commit[1] for more
77 details. In particular, if the '<mode>' is given a value of `scissors`,
78 scissors will be appended to `MERGE_MSG` before being passed on in the case
79 of a conflict.
80
81-n::
82--no-commit::
83 Usually the command automatically creates some commits with
84 commit log messages stating which commits were
85 reverted. This flag applies the changes necessary
86 to revert the named commits to your working tree
87 and the index, but does not make the commits. In addition,
88 when this option is used, your index does not have to match
89 the HEAD commit. The revert is done against the
90 beginning state of your index.
91+
92This is useful when reverting more than one commits'
93effect to your index in a row.
94
95-S[<keyid>]::
96--gpg-sign[=<keyid>]::
97--no-gpg-sign::
98 GPG-sign commits. The `keyid` argument is optional and
99 defaults to the committer identity; if specified, it must be
100 stuck to the option without a space. `--no-gpg-sign` is useful to
101 countermand both `commit.gpgSign` configuration variable, and
102 earlier `--gpg-sign`.
103
104-s::
105--signoff::
106 Add a `Signed-off-by` trailer at the end of the commit message.
107 See the signoff option in linkgit:git-commit[1] for more information.
108
109--strategy=<strategy>::
110 Use the given merge strategy. Should only be used once.
111 See the MERGE STRATEGIES section in linkgit:git-merge[1]
112 for details.
113
114-X<option>::
115--strategy-option=<option>::
116 Pass the merge strategy-specific option through to the
117 merge strategy. See linkgit:git-merge[1] for details.
118
119include::rerere-options.adoc[]
120
121--reference::
122 Instead of starting the body of the log message with "This
123 reverts <full-object-name-of-the-commit-being-reverted>.",
124 refer to the commit using "--pretty=reference" format
125 (cf. linkgit:git-log[1]). The `revert.reference`
126 configuration variable can be used to enable this option by
127 default.
128
129
130SEQUENCER SUBCOMMANDS
131---------------------
132include::sequencer.adoc[]
133
134EXAMPLES
135--------
136`git revert HEAD~3`::
137
138 Revert the changes specified by the fourth last commit in HEAD
139 and create a new commit with the reverted changes.
140
141`git revert -n master~5..master~2`::
142
143 Revert the changes done by commits from the fifth last commit
144 in master (included) to the third last commit in master
145 (included), but do not create any commit with the reverted
146 changes. The revert only modifies the working tree and the
147 index.
148
149DISCUSSION
150----------
151
152While git creates a basic commit message automatically, it is
153_strongly_ recommended to explain why the original commit is being
154reverted.
155In addition, repeatedly reverting reverts will result in increasingly
156unwieldy subject lines, for example 'Reapply "Reapply "<original-subject>""'.
157Please consider rewording these to be shorter and more unique.
158
159CONFIGURATION
160-------------
161
162include::includes/cmd-config-section-all.adoc[]
163
164include::config/revert.adoc[]
165
166SEE ALSO
167--------
168linkgit:git-cherry-pick[1]
169linkgit:gitmergeconflicts[7]
170
171GIT
172---
173Part of the linkgit:git[1] suite