blob: 70152e8b1eb31e5ed6e7da889a424bc65c1f16c2 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231git-revert(1)
2=============
3
4NAME
5----
Junio C Hamano89a57342010-06-22 23:22:556git-revert - Revert some existing commits
Junio C Hamano1a4e8412005-12-27 08:17:237
8SYNOPSIS
9--------
Junio C Hamano15567bc2011-07-23 00:51:5910[verse]
Junio C Hamano89a57342010-06-22 23:22:5511'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>...
Junio C Hamano8fb66e52011-10-05 20:59:5112'git revert' --continue
Junio C Hamanof0944d02011-11-30 20:46:2913'git revert' --quit
14'git revert' --abort
Junio C Hamano1a4e8412005-12-27 08:17:2315
16DESCRIPTION
17-----------
Junio C Hamano1a4e8412005-12-27 08:17:2318
Junio C Hamano89a57342010-06-22 23:22:5519Given one or more existing commits, revert the changes that the
20related patches introduce, and record some new commits that record
21them. This requires your working tree to be clean (no modifications
22from the HEAD commit).
23
24Note: 'git revert' is used to record some new commits to reverse the
25effect of some earlier commits (often only a faulty one). If you want to
Junio C Hamano3580ad22008-08-21 00:27:4026throw away all uncommitted changes in your working directory, you
27should see linkgit:git-reset[1], particularly the '--hard' option. If
28you want to extract specific files as they were in another commit, you
Junio C Hamano1aa40d22010-01-21 17:46:4329should see linkgit:git-checkout[1], specifically the `git checkout
Junio C Hamanob76a6862012-05-02 22:02:4630<commit> -- <filename>` syntax. Take care with these alternatives as
Junio C Hamano3580ad22008-08-21 00:27:4031both will discard uncommitted changes in your working directory.
32
Junio C Hamano1a4e8412005-12-27 08:17:2333OPTIONS
34-------
Junio C Hamano89a57342010-06-22 23:22:5535<commit>...::
36Commits to revert.
Junio C Hamano2d47c622007-01-18 06:24:1037For a more complete list of ways to spell commit names, see
Junio C Hamanoc27b7332010-10-14 04:37:2838linkgit:gitrevisions[7].
Junio C Hamano89a57342010-06-22 23:22:5539Sets of commits can also be given but no traversal is done by
40default, see linkgit:git-rev-list[1] and its '--no-walk'
41option.
Junio C Hamano1a4e8412005-12-27 08:17:2342
Junio C Hamanoeb415992008-06-08 22:49:4743-e::
44--edit::
Junio C Hamano1aa40d22010-01-21 17:46:4345With this option, 'git revert' will let you edit the commit
Junio C Hamano0e661132008-01-21 02:37:4446message prior to committing the revert. This is the default if
Junio C Hamano1a4e8412005-12-27 08:17:2347you run the command from a terminal.
48
Junio C Hamanoeb415992008-06-08 22:49:4749-m parent-number::
50--mainline parent-number::
Junio C Hamanod814b6d2007-11-04 11:13:4951Usually you cannot revert a merge because you do not know which
52side of the merge should be considered the mainline. This
53option specifies the parent number (starting from 1) of
54the mainline and allows revert to reverse the change
55relative to the specified parent.
Junio C Hamanof1231492008-12-22 08:27:2156+
57Reverting a merge commit declares that you will never want the tree changes
58brought in by the merge. As a result, later merges will only bring in tree
59changes introduced by commits that are not ancestors of the previously
60reverted merge. This may or may not be what you want.
61+
62See the link:howto/revert-a-faulty-merge.txt[revert-a-faulty-merge How-To] for
63more details.
Junio C Hamanod814b6d2007-11-04 11:13:4964
Junio C Hamano1a4e8412005-12-27 08:17:2365--no-edit::
Junio C Hamano1aa40d22010-01-21 17:46:4366With this option, 'git revert' will not start the commit
Junio C Hamano1a4e8412005-12-27 08:17:2367message editor.
68
Junio C Hamanoeb415992008-06-08 22:49:4769-n::
70--no-commit::
Junio C Hamano89a57342010-06-22 23:22:5571Usually the command automatically creates some commits with
72commit log messages stating which commits were
73reverted. This flag applies the changes necessary
74to revert the named commits to your working tree
75and the index, but does not make the commits. In addition,
Junio C Hamanof69a0a02008-07-17 08:08:4776when this option is used, your index does not have to match
77the HEAD commit. The revert is done against the
78beginning state of your index.
Junio C Hamano1a4e8412005-12-27 08:17:2379+
80This is useful when reverting more than one commits'
Junio C Hamanof69a0a02008-07-17 08:08:4781effect to your index in a row.
Junio C Hamano1a4e8412005-12-27 08:17:2382
Junio C Hamanoeb415992008-06-08 22:49:4783-s::
84--signoff::
Junio C Hamano6d76d612008-05-09 05:46:0885Add Signed-off-by line at the end of the commit message.
86
Junio C Hamano23e3f532011-02-10 02:05:2987--strategy=<strategy>::
88Use the given merge strategy. Should only be used once.
89See the MERGE STRATEGIES section in linkgit:git-merge[1]
90for details.
91
92-X<option>::
93--strategy-option=<option>::
94Pass the merge strategy-specific option through to the
95merge strategy. See linkgit:git-merge[1] for details.
96
Junio C Hamano8fb66e52011-10-05 20:59:5197SEQUENCER SUBCOMMANDS
98---------------------
99include::sequencer.txt[]
100
Junio C Hamano89a57342010-06-22 23:22:55101EXAMPLES
102--------
Junio C Hamano16ebcd02011-08-05 00:05:45103`git revert HEAD~3`::
Junio C Hamano89a57342010-06-22 23:22:55104
105Revert the changes specified by the fourth last commit in HEAD
106and create a new commit with the reverted changes.
107
Junio C Hamanob76a6862012-05-02 22:02:46108`git revert -n master~5..master~2`::
Junio C Hamano89a57342010-06-22 23:22:55109
110Revert the changes done by commits from the fifth last commit
111in master (included) to the third last commit in master
112(included), but do not create any commit with the reverted
113changes. The revert only modifies the working tree and the
114index.
Junio C Hamano1a4e8412005-12-27 08:17:23115
Junio C Hamano89a57342010-06-22 23:22:55116SEE ALSO
117--------
118linkgit:git-cherry-pick[1]
119
Junio C Hamano1a4e8412005-12-27 08:17:23120GIT
121---
Junio C Hamanof7c042d2008-06-06 22:50:53122Part of the linkgit:git[1] suite