2005-09-08 02:26:23 +02:00
|
|
|
git-revert(1)
|
|
|
|
=============
|
2005-08-23 10:49:47 +02:00
|
|
|
|
|
|
|
NAME
|
|
|
|
----
|
2010-06-02 07:58:41 +02:00
|
|
|
git-revert - Revert some existing commits
|
2005-08-23 10:49:47 +02:00
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
--------
|
2010-06-02 07:58:41 +02:00
|
|
|
'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>...
|
2005-08-23 10:49:47 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
|
2010-06-02 07:58:41 +02: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 21:50:31 +02: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 17:49:12 +01:00
|
|
|
should see linkgit:git-checkout[1], specifically the `git checkout
|
|
|
|
<commit> -- <filename>` syntax. Take care with these alternatives as
|
2008-08-19 21:50:31 +02:00
|
|
|
both will discard uncommitted changes in your working directory.
|
|
|
|
|
2005-08-23 10:49:47 +02:00
|
|
|
OPTIONS
|
|
|
|
-------
|
2010-06-02 07:58:41 +02:00
|
|
|
<commit>...::
|
|
|
|
Commits to revert.
|
2007-01-18 03:08:09 +01:00
|
|
|
For a more complete list of ways to spell commit names, see
|
2010-10-11 18:03:32 +02:00
|
|
|
linkgit:gitrevisions[7].
|
2010-06-02 07:58:41 +02: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 10:49:47 +02:00
|
|
|
|
2008-06-08 03:36:09 +02:00
|
|
|
-e::
|
|
|
|
--edit::
|
2010-01-10 00:33:00 +01:00
|
|
|
With this option, 'git revert' will let you edit the commit
|
2008-01-19 16:23:32 +01:00
|
|
|
message prior to committing the revert. This is the default if
|
2005-11-26 23:12:44 +01:00
|
|
|
you run the command from a terminal.
|
|
|
|
|
2008-06-08 03:36:09 +02:00
|
|
|
-m parent-number::
|
|
|
|
--mainline parent-number::
|
2007-10-23 22:33:26 +02: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 01:26:03 +01: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-23 22:33:26 +02:00
|
|
|
|
2005-11-26 23:12:44 +01:00
|
|
|
--no-edit::
|
2010-01-10 00:33:00 +01:00
|
|
|
With this option, 'git revert' will not start the commit
|
2005-11-26 23:12:44 +01:00
|
|
|
message editor.
|
|
|
|
|
2008-06-08 03:36:09 +02:00
|
|
|
-n::
|
|
|
|
--no-commit::
|
2010-06-02 07:58:41 +02: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 14:35:22 +02: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 19:16:30 +02:00
|
|
|
+
|
|
|
|
This is useful when reverting more than one commits'
|
2008-07-16 14:35:22 +02:00
|
|
|
effect to your index in a row.
|
2005-08-28 12:01:09 +02:00
|
|
|
|
2008-06-08 03:36:09 +02:00
|
|
|
-s::
|
|
|
|
--signoff::
|
2008-04-26 22:14:28 +02:00
|
|
|
Add Signed-off-by line at the end of the commit message.
|
|
|
|
|
2010-06-02 07:58:41 +02: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.
|
|
|
|
|
|
|
|
git revert -n master\~5..master~2::
|
|
|
|
|
|
|
|
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 12:01:09 +02:00
|
|
|
|
2005-08-23 10:49:47 +02:00
|
|
|
Author
|
|
|
|
------
|
2008-07-21 21:14:42 +02:00
|
|
|
Written by Junio C Hamano <gitster@pobox.com>
|
2005-08-23 10:49:47 +02:00
|
|
|
|
|
|
|
Documentation
|
|
|
|
--------------
|
|
|
|
Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
|
|
|
|
|
2010-06-02 07:58:41 +02:00
|
|
|
SEE ALSO
|
|
|
|
--------
|
|
|
|
linkgit:git-cherry-pick[1]
|
|
|
|
|
2005-08-23 10:49:47 +02:00
|
|
|
GIT
|
|
|
|
---
|
2008-06-06 09:07:32 +02:00
|
|
|
Part of the linkgit:git[1] suite
|