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] <commit>...
10 git revert --continue
11 git revert --quit
12 git revert --abort
13
14
16 Given one or more existing commits, revert the changes that the related
17 patches introduce, and record some new commits that record them. This
18 requires your working tree to be clean (no modifications from the HEAD
19 commit).
20
21 Note: git revert is used to record some new commits to reverse the
22 effect of some earlier commits (often only a faulty one). If you want
23 to throw away all uncommitted changes in your working directory, you
24 should see git-reset(1), particularly the --hard option. If you want to
25 extract specific files as they were in another commit, you should see
26 git-checkout(1), specifically the git checkout <commit> -- <filename>
27 syntax. Take care with these alternatives as both will discard
28 uncommitted changes in your working directory.
29
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 -n, --no-commit
62 Usually the command automatically creates some commits with commit
63 log messages stating which commits were reverted. This flag applies
64 the changes necessary to revert the named commits to your working
65 tree and the index, but does not make the commits. In addition,
66 when this option is used, your index does not have to match the
67 HEAD commit. The revert is done against the beginning state of your
68 index.
69
70 This is useful when reverting more than one commits' effect to your
71 index in a row.
72
73 -s, --signoff
74 Add Signed-off-by line at the end of the commit message.
75
76 --strategy=<strategy>
77 Use the given merge strategy. Should only be used once. See the
78 MERGE STRATEGIES section in git-merge(1) for details.
79
80 -X<option>, --strategy-option=<option>
81 Pass the merge strategy-specific option through to the merge
82 strategy. See git-merge(1) for details.
83
85 --continue
86 Continue the operation in progress using the information in
87 .git/sequencer. Can be used to continue after resolving conflicts
88 in a failed cherry-pick or revert.
89
90 --quit
91 Forget about the current operation in progress. Can be used to
92 clear the sequencer state after a failed cherry-pick or revert.
93
94 --abort
95 Cancel the operation and return to the pre-sequence state.
96
98 git revert HEAD~3
99 Revert the changes specified by the fourth last commit in HEAD and
100 create a new commit with the reverted changes.
101
102 git revert -n master~5..master~2
103 Revert the changes done by commits from the fifth last commit in
104 master (included) to the third last commit in master (included),
105 but do not create any commit with the reverted changes. The revert
106 only modifies the working tree and the index.
107
109 git-cherry-pick(1)
110
112 Part of the git(1) suite
113
115 1. revert-a-faulty-merge How-To
116 file:///usr/share/doc/git-1.8.3.1/howto/revert-a-faulty-merge.txt
117
118
119
120Git 1.8.3.1 11/19/2018 GIT-REVERT(1)