1GIT-REVERT(1) Git Manual GIT-REVERT(1)
2
3
4
6 git-revert - Revert some existing commits
7
9 git revert [--edit | --no-edit] [-n] [-m parent-number] [-s]
10 <commit>...
11
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-checkout(1), specifically the git checkout <commit> — <filename>
24 syntax. Take care with these alternatives as both will discard
25 uncommitted changes in your working directory.
26
28 <commit>...
29 Commits to revert. For a more complete list of ways to spell commit
30 names, see gitrevisions(7). Sets of commits can also be given but
31 no traversal is done by default, see git-rev-list(1) and its
32 --no-walk option.
33
34 -e, --edit
35 With this option, git revert will let you edit the commit message
36 prior to committing the revert. This is the default if you run the
37 command from a terminal.
38
39 -m parent-number, --mainline parent-number
40 Usually you cannot revert a merge because you do not know which
41 side of the merge should be considered the mainline. This option
42 specifies the parent number (starting from 1) of the mainline and
43 allows revert to reverse the change relative to the specified
44 parent.
45
46 Reverting a merge commit declares that you will never want the tree
47 changes brought in by the merge. As a result, later merges will
48 only bring in tree changes introduced by commits that are not
49 ancestors of the previously reverted merge. This may or may not be
50 what you want.
51
52 See the revert-a-faulty-merge How-To[1] for more details.
53
54 --no-edit
55 With this option, git revert will not start the commit message
56 editor.
57
58 -n, --no-commit
59 Usually the command automatically creates some commits with commit
60 log messages stating which commits were reverted. This flag applies
61 the changes necessary to revert the named commits to your working
62 tree and the index, but does not make the commits. In addition,
63 when this option is used, your index does not have to match the
64 HEAD commit. The revert is done against the beginning state of your
65 index.
66
67 This is useful when reverting more than one commits' effect to your
68 index in a row.
69
70 -s, --signoff
71 Add Signed-off-by line at the end of the commit message.
72
74 git revert HEAD~3
75 Revert the changes specified by the fourth last commit in HEAD and
76 create a new commit with the reverted changes.
77
78 git revert -n master~5..master~2
79 Revert the changes done by commits from the fifth last commit in
80 master (included) to the third last commit in master (included),
81 but do not create any commit with the reverted changes. The revert
82 only modifies the working tree and the index.
83
85 Written by Junio C Hamano <gitster@pobox.com[2]>
86
88 Documentation by Junio C Hamano and the git-list
89 <git@vger.kernel.org[3]>.
90
92 git-cherry-pick(1)
93
95 Part of the git(1) suite
96
98 1. revert-a-faulty-merge How-To
99 file:///usr/share/doc/git-1.7.4.4/howto/revert-a-faulty-merge.txt
100
101 2. gitster@pobox.com
102 mailto:gitster@pobox.com
103
104 3. git@vger.kernel.org
105 mailto:git@vger.kernel.org
106
107
108
109Git 1.7.4.4 04/11/2011 GIT-REVERT(1)