1GIT-REVERT(1)                     Git Manual                     GIT-REVERT(1)
2
3
4

NAME

6       git-revert - Revert some existing commits
7

SYNOPSIS

9       git revert [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>...
10       git revert (--continue | --skip | --abort | --quit)
11

DESCRIPTION

13       Given one or more existing commits, revert the changes that the related
14       patches introduce, and record some new commits that record them. This
15       requires your working tree to be clean (no modifications from the HEAD
16       commit).
17
18       Note: git revert is used to record some new commits to reverse the
19       effect of some earlier commits (often only a faulty one). If you want
20       to throw away all uncommitted changes in your working directory, you
21       should see git-reset(1), particularly the --hard option. If you want to
22       extract specific files as they were in another commit, you should see
23       git-restore(1), specifically the --source option. Take care with these
24       alternatives as both will discard uncommitted changes in your working
25       directory.
26
27       See "Reset, restore and revert" in git(1) for the differences between
28       the three commands.
29

OPTIONS

31       <commit>...
32           Commits to revert. For a more complete list of ways to spell commit
33           names, see gitrevisions(7). Sets of commits can also be given but
34           no traversal is done by default, see git-rev-list(1) and its
35           --no-walk option.
36
37       -e, --edit
38           With this option, git revert will let you edit the commit message
39           prior to committing the revert. This is the default if you run the
40           command from a terminal.
41
42       -m parent-number, --mainline parent-number
43           Usually you cannot revert a merge because you do not know which
44           side of the merge should be considered the mainline. This option
45           specifies the parent number (starting from 1) of the mainline and
46           allows revert to reverse the change relative to the specified
47           parent.
48
49           Reverting a merge commit declares that you will never want the tree
50           changes brought in by the merge. As a result, later merges will
51           only bring in tree changes introduced by commits that are not
52           ancestors of the previously reverted merge. This may or may not be
53           what you want.
54
55           See the revert-a-faulty-merge How-To[1] for more details.
56
57       --no-edit
58           With this option, git revert will not start the commit message
59           editor.
60
61       --cleanup=<mode>
62           This option determines how the commit message will be cleaned up
63           before being passed on to the commit machinery. See git-commit(1)
64           for more details. In particular, if the <mode> is given a value of
65           scissors, scissors will be appended to MERGE_MSG before being
66           passed on in the case of a conflict.
67
68       -n, --no-commit
69           Usually the command automatically creates some commits with commit
70           log messages stating which commits were reverted. This flag applies
71           the changes necessary to revert the named commits to your working
72           tree and the index, but does not make the commits. In addition,
73           when this option is used, your index does not have to match the
74           HEAD commit. The revert is done against the beginning state of your
75           index.
76
77           This is useful when reverting more than one commits' effect to your
78           index in a row.
79
80       -S[<keyid>], --gpg-sign[=<keyid>]
81           GPG-sign commits. The keyid argument is optional and defaults to
82           the committer identity; if specified, it must be stuck to the
83           option without a space.
84
85       -s, --signoff
86           Add Signed-off-by line at the end of the commit message. See the
87           signoff option in git-commit(1) for more information.
88
89       --strategy=<strategy>
90           Use the given merge strategy. Should only be used once. See the
91           MERGE STRATEGIES section in git-merge(1) for details.
92
93       -X<option>, --strategy-option=<option>
94           Pass the merge strategy-specific option through to the merge
95           strategy. See git-merge(1) for details.
96
97       --rerere-autoupdate, --no-rerere-autoupdate
98           Allow the rerere mechanism to update the index with the result of
99           auto-conflict resolution if possible.
100

SEQUENCER SUBCOMMANDS

102       --continue
103           Continue the operation in progress using the information in
104           .git/sequencer. Can be used to continue after resolving conflicts
105           in a failed cherry-pick or revert.
106
107       --skip
108           Skip the current commit and continue with the rest of the sequence.
109
110       --quit
111           Forget about the current operation in progress. Can be used to
112           clear the sequencer state after a failed cherry-pick or revert.
113
114       --abort
115           Cancel the operation and return to the pre-sequence state.
116

EXAMPLES

118       git revert HEAD~3
119           Revert the changes specified by the fourth last commit in HEAD and
120           create a new commit with the reverted changes.
121
122       git revert -n master~5..master~2
123           Revert the changes done by commits from the fifth last commit in
124           master (included) to the third last commit in master (included),
125           but do not create any commit with the reverted changes. The revert
126           only modifies the working tree and the index.
127

SEE ALSO

129       git-cherry-pick(1)
130

GIT

132       Part of the git(1) suite
133

NOTES

135        1. revert-a-faulty-merge How-To
136           file:///usr/share/doc/git/howto/revert-a-faulty-merge.html
137
138
139
140Git 2.26.2                        2020-04-20                     GIT-REVERT(1)
Impressum