2005-09-08 04:26:23 +04:00
|
|
|
git-revert(1)
|
|
|
|
=============
|
2005-08-23 12:49:47 +04:00
|
|
|
|
|
|
|
NAME
|
|
|
|
----
|
2010-06-02 09:58:41 +04:00
|
|
|
git-revert - Revert some existing commits
|
2005-08-23 12:49:47 +04:00
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
--------
|
2010-06-02 09:58:41 +04:00
|
|
|
'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>...
|
2005-08-23 12:49:47 +04:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
|
2010-06-02 09:58:41 +04:00
|
|
|
Given one or more existing commits, revert the changes that the
|
|
|
|
related patches introduce, and record some new commits that record
|
|
|
|
them. This requires your working tree to be clean (no modifications
|
|
|
|
from the HEAD commit).
|
|
|
|
|
|
|
|
Note: 'git revert' is used to record some new commits to reverse the
|
|
|
|
effect of some earlier commits (often only a faulty one). If you want to
|
2008-08-19 23:50:31 +04:00
|
|
|
throw away all uncommitted changes in your working directory, you
|
|
|
|
should see linkgit:git-reset[1], particularly the '--hard' option. If
|
|
|
|
you want to extract specific files as they were in another commit, you
|
2010-01-07 19:49:12 +03:00
|
|
|
should see linkgit:git-checkout[1], specifically the `git checkout
|
|
|
|
<commit> -- <filename>` syntax. Take care with these alternatives as
|
2008-08-19 23:50:31 +04:00
|
|
|
both will discard uncommitted changes in your working directory.
|
|
|
|
|
2005-08-23 12:49:47 +04:00
|
|
|
OPTIONS
|
|
|
|
-------
|
2010-06-02 09:58:41 +04:00
|
|
|
<commit>...::
|
|
|
|
Commits to revert.
|
2007-01-18 05:08:09 +03:00
|
|
|
For a more complete list of ways to spell commit names, see
|
2010-10-11 20:03:32 +04:00
|
|
|
linkgit:gitrevisions[7].
|
2010-06-02 09:58:41 +04:00
|
|
|
Sets of commits can also be given but no traversal is done by
|
|
|
|
default, see linkgit:git-rev-list[1] and its '--no-walk'
|
|
|
|
option.
|
2005-08-23 12:49:47 +04:00
|
|
|
|
2008-06-08 05:36:09 +04:00
|
|
|
-e::
|
|
|
|
--edit::
|
2010-01-10 02:33:00 +03:00
|
|
|
With this option, 'git revert' will let you edit the commit
|
2008-01-19 18:23:32 +03:00
|
|
|
message prior to committing the revert. This is the default if
|
2005-11-27 01:12:44 +03:00
|
|
|
you run the command from a terminal.
|
|
|
|
|
2008-06-08 05:36:09 +04:00
|
|
|
-m parent-number::
|
|
|
|
--mainline parent-number::
|
2007-10-24 00:33:26 +04:00
|
|
|
Usually you cannot revert a merge because you do not know which
|
|
|
|
side of the merge should be considered the mainline. This
|
|
|
|
option specifies the parent number (starting from 1) of
|
|
|
|
the mainline and allows revert to reverse the change
|
|
|
|
relative to the specified parent.
|
2008-12-22 03:26:03 +03:00
|
|
|
+
|
|
|
|
Reverting a merge commit declares that you will never want the tree changes
|
|
|
|
brought in by the merge. As a result, later merges will only bring in tree
|
|
|
|
changes introduced by commits that are not ancestors of the previously
|
|
|
|
reverted merge. This may or may not be what you want.
|
|
|
|
+
|
|
|
|
See the link:howto/revert-a-faulty-merge.txt[revert-a-faulty-merge How-To] for
|
|
|
|
more details.
|
2007-10-24 00:33:26 +04:00
|
|
|
|
2005-11-27 01:12:44 +03:00
|
|
|
--no-edit::
|
2010-01-10 02:33:00 +03:00
|
|
|
With this option, 'git revert' will not start the commit
|
2005-11-27 01:12:44 +03:00
|
|
|
message editor.
|
|
|
|
|
2008-06-08 05:36:09 +04:00
|
|
|
-n::
|
|
|
|
--no-commit::
|
2010-06-02 09:58:41 +04:00
|
|
|
Usually the command automatically creates some commits with
|
|
|
|
commit log messages stating which commits were
|
|
|
|
reverted. This flag applies the changes necessary
|
|
|
|
to revert the named commits to your working tree
|
|
|
|
and the index, but does not make the commits. In addition,
|
2008-07-16 16:35:22 +04:00
|
|
|
when this option is used, your index does not have to match
|
|
|
|
the HEAD commit. The revert is done against the
|
|
|
|
beginning state of your index.
|
2005-10-03 21:16:30 +04:00
|
|
|
+
|
|
|
|
This is useful when reverting more than one commits'
|
2008-07-16 16:35:22 +04:00
|
|
|
effect to your index in a row.
|
2005-08-28 14:01:09 +04:00
|
|
|
|
2008-06-08 05:36:09 +04:00
|
|
|
-s::
|
|
|
|
--signoff::
|
2008-04-27 00:14:28 +04:00
|
|
|
Add Signed-off-by line at the end of the commit message.
|
|
|
|
|
2010-12-11 03:51:44 +03:00
|
|
|
--strategy=<strategy>::
|
|
|
|
Use the given merge strategy. Should only be used once.
|
|
|
|
See the MERGE STRATEGIES section in linkgit:git-merge[1]
|
|
|
|
for details.
|
|
|
|
|
|
|
|
-X<option>::
|
|
|
|
--strategy-option=<option>::
|
|
|
|
Pass the merge strategy-specific option through to the
|
|
|
|
merge strategy. See linkgit:git-merge[1] for details.
|
|
|
|
|
2010-06-02 09:58:41 +04:00
|
|
|
EXAMPLES
|
|
|
|
--------
|
|
|
|
git revert HEAD~3::
|
|
|
|
|
|
|
|
Revert the changes specified by the fourth last commit in HEAD
|
|
|
|
and create a new commit with the reverted changes.
|
|
|
|
|
2010-12-02 22:23:50 +03:00
|
|
|
git revert -n master{tilde}5..master{tilde}2::
|
2010-06-02 09:58:41 +04:00
|
|
|
|
|
|
|
Revert the changes done by commits from the fifth last commit
|
|
|
|
in master (included) to the third last commit in master
|
|
|
|
(included), but do not create any commit with the reverted
|
|
|
|
changes. The revert only modifies the working tree and the
|
|
|
|
index.
|
2005-08-28 14:01:09 +04:00
|
|
|
|
2010-06-02 09:58:41 +04:00
|
|
|
SEE ALSO
|
|
|
|
--------
|
|
|
|
linkgit:git-cherry-pick[1]
|
|
|
|
|
2005-08-23 12:49:47 +04:00
|
|
|
GIT
|
|
|
|
---
|
2008-06-06 11:07:32 +04:00
|
|
|
Part of the linkgit:git[1] suite
|