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>], --no-gpg-sign
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.  --no-gpg-sign is useful to countermand
84           both commit.gpgSign configuration variable, and earlier --gpg-sign.
85
86       -s, --signoff
87           Add a Signed-off-by trailer at the end of the commit message. See
88           the signoff option in git-commit(1) for more information.
89
90       --strategy=<strategy>
91           Use the given merge strategy. Should only be used once. See the
92           MERGE STRATEGIES section in git-merge(1) for details.
93
94       -X<option>, --strategy-option=<option>
95           Pass the merge strategy-specific option through to the merge
96           strategy. See git-merge(1) for details.
97
98       --rerere-autoupdate, --no-rerere-autoupdate
99           Allow the rerere mechanism to update the index with the result of
100           auto-conflict resolution if possible.
101

SEQUENCER SUBCOMMANDS

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

EXAMPLES

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

SEE ALSO

130       git-cherry-pick(1)
131

GIT

133       Part of the git(1) suite
134

NOTES

136        1. revert-a-faulty-merge How-To
137           file:///usr/share/doc/git/howto/revert-a-faulty-merge.html
138
139
140
141Git 2.30.2                        2021-03-08                     GIT-REVERT(1)
Impressum