1GIT-REVERT(1) Git Manual GIT-REVERT(1)
2
3
4
6 git-revert - Revert some existing commits
7
9 git revert [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>...
10 git revert (--continue | --skip | --abort | --quit)
11
12
14 Given one or more existing commits, revert the changes that the related
15 patches introduce, and record some new commits that record them. This
16 requires your working tree to be clean (no modifications from the HEAD
17 commit).
18
19 Note: git revert is used to record some new commits to reverse the
20 effect of some earlier commits (often only a faulty one). If you want
21 to throw away all uncommitted changes in your working directory, you
22 should see git-reset(1), particularly the --hard option. If you want to
23 extract specific files as they were in another commit, you should see
24 git-restore(1), specifically the --source option. Take care with these
25 alternatives as both will discard uncommitted changes in your working
26 directory.
27
28 See "Reset, restore and revert" in git(1) for the differences between
29 the three commands.
30
32 <commit>...
33 Commits to revert. For a more complete list of ways to spell commit
34 names, see gitrevisions(7). Sets of commits can also be given but
35 no traversal is done by default, see git-rev-list(1) and its
36 --no-walk option.
37
38 -e, --edit
39 With this option, git revert will let you edit the commit message
40 prior to committing the revert. This is the default if you run the
41 command from a terminal.
42
43 -m parent-number, --mainline parent-number
44 Usually you cannot revert a merge because you do not know which
45 side of the merge should be considered the mainline. This option
46 specifies the parent number (starting from 1) of the mainline and
47 allows revert to reverse the change relative to the specified
48 parent.
49
50 Reverting a merge commit declares that you will never want the tree
51 changes brought in by the merge. As a result, later merges will
52 only bring in tree changes introduced by commits that are not
53 ancestors of the previously reverted merge. This may or may not be
54 what you want.
55
56 See the revert-a-faulty-merge How-To[1] for more details.
57
58 --no-edit
59 With this option, git revert will not start the commit message
60 editor.
61
62 --cleanup=<mode>
63 This option determines how the commit message will be cleaned up
64 before being passed on to the commit machinery. See git-commit(1)
65 for more details. In particular, if the <mode> is given a value of
66 scissors, scissors will be appended to MERGE_MSG before being
67 passed on in the case of a conflict.
68
69 -n, --no-commit
70 Usually the command automatically creates some commits with commit
71 log messages stating which commits were reverted. This flag applies
72 the changes necessary to revert the named commits to your working
73 tree and the index, but does not make the commits. In addition,
74 when this option is used, your index does not have to match the
75 HEAD commit. The revert is done against the beginning state of your
76 index.
77
78 This is useful when reverting more than one commits' effect to your
79 index in a row.
80
81 -S[<keyid>], --gpg-sign[=<keyid>]
82 GPG-sign commits. The keyid argument is optional and defaults to
83 the committer identity; if specified, it must be stuck to the
84 option without a space.
85
86 -s, --signoff
87 Add Signed-off-by line at the end of the commit message. See the
88 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
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
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
130 git-cherry-pick(1)
131
133 Part of the git(1) suite
134
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.24.1 12/10/2019 GIT-REVERT(1)