2005-09-08 00:26:23 +00:00
|
|
|
git-revert(1)
|
|
|
|
=============
|
2005-08-23 08:49:47 +00:00
|
|
|
|
|
|
|
NAME
|
|
|
|
----
|
2010-06-02 05:58:41 +00:00
|
|
|
git-revert - Revert some existing commits
|
2005-08-23 08:49:47 +00:00
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
--------
|
2011-07-02 02:38:26 +00:00
|
|
|
[verse]
|
2010-06-02 05:58:41 +00:00
|
|
|
'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>...
|
2011-08-04 10:39:15 +00:00
|
|
|
'git revert' --continue
|
2011-11-22 11:14:29 +00:00
|
|
|
'git revert' --quit
|
2011-11-23 01:27:21 +00:00
|
|
|
'git revert' --abort
|
2005-08-23 08:49:47 +00:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
|
2010-06-02 05:58:41 +00: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 19:50:31 +00: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 16:49:12 +00:00
|
|
|
should see linkgit:git-checkout[1], specifically the `git checkout
|
Documentation: quote double-dash for AsciiDoc
AsciiDoc versions since 5.0.6 treat a double-dash surrounded by spaces
(outside of verbatim environments) as a request to insert an em dash.
Such versions also treat the three-character sequence "\--", when not
followed by another dash, as a request to insert two literal minus
signs. Thus from time to time there have been patches to add
backslashes to AsciiDoc markup to escape double-dashes that are meant
to be represent '--' characters used literally on the command line;
see v1.4.0-rc1~174, Fix up docs where "--" isn't displayed correctly,
2006-05-05, for example.
AsciiDoc 6.0.3 (2005-04-20) made life harder by also treating
double-dashes without surrounding whitespace as markup for an em dash,
though only when formatting for backends other than the manpages
(e.g., HTML). Many pages needed to be changed to use a backslash
before the "--" in names of command-line flags like "--add" (see
v0.99.6~37, Update tutorial, 2005-08-30).
AsciiDoc 8.3.0 (2008-11-29) refined the em-dash rule to avoid that
requirement. Double-dashes without surrounding spaces are not
rendered as em dashes any more unless bordered on both sides by
alphanumeric characters. The unescaped markup for option names (e.g.,
"--add") works fine, and many instances of this style have leaked into
Documentation/; git's HTML documentation contains many spurious em
dashes when formatted by an older toolchain. (This patch will not
change that.)
The upshot: "--" as an isolated word and in phrases like "git
web--browse" must be escaped if it is not to be rendered as an em dash
by current asciidoc. Use "\--" to avoid such misformatting in
sentences in which "--" represents a literal double-minus command line
argument that separates options and revs from pathspecs, and use
"{litdd}" in cases where the double-dash is embedded in the command
name. The latter is just for consistency with v1.7.3-rc0~13^2 (Work
around em-dash handling in newer AsciiDoc, 2010-08-23).
List of lines to fix found by grepping manpages for "(em".
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Improved-by: Junio C Hamano <gitster@pobox.com>
Improved-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-06-29 05:35:10 +00:00
|
|
|
<commit> \-- <filename>` syntax. Take care with these alternatives as
|
2008-08-19 19:50:31 +00:00
|
|
|
both will discard uncommitted changes in your working directory.
|
|
|
|
|
2005-08-23 08:49:47 +00:00
|
|
|
OPTIONS
|
|
|
|
-------
|
2010-06-02 05:58:41 +00:00
|
|
|
<commit>...::
|
|
|
|
Commits to revert.
|
2007-01-18 02:08:09 +00:00
|
|
|
For a more complete list of ways to spell commit names, see
|
2010-10-11 16:03:32 +00:00
|
|
|
linkgit:gitrevisions[7].
|
2010-06-02 05:58:41 +00: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 08:49:47 +00:00
|
|
|
|
2008-06-08 01:36:09 +00:00
|
|
|
-e::
|
|
|
|
--edit::
|
2010-01-09 23:33:00 +00:00
|
|
|
With this option, 'git revert' will let you edit the commit
|
2008-01-19 15:23:32 +00:00
|
|
|
message prior to committing the revert. This is the default if
|
2005-11-26 22:12:44 +00:00
|
|
|
you run the command from a terminal.
|
|
|
|
|
2008-06-08 01:36:09 +00:00
|
|
|
-m parent-number::
|
|
|
|
--mainline parent-number::
|
2007-10-23 20:33:26 +00: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 00:26:03 +00: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 20:33:26 +00:00
|
|
|
|
2005-11-26 22:12:44 +00:00
|
|
|
--no-edit::
|
2010-01-09 23:33:00 +00:00
|
|
|
With this option, 'git revert' will not start the commit
|
2005-11-26 22:12:44 +00:00
|
|
|
message editor.
|
|
|
|
|
2008-06-08 01:36:09 +00:00
|
|
|
-n::
|
|
|
|
--no-commit::
|
2010-06-02 05:58:41 +00: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 12:35:22 +00: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 17:16:30 +00:00
|
|
|
+
|
|
|
|
This is useful when reverting more than one commits'
|
2008-07-16 12:35:22 +00:00
|
|
|
effect to your index in a row.
|
2005-08-28 10:01:09 +00:00
|
|
|
|
2008-06-08 01:36:09 +00:00
|
|
|
-s::
|
|
|
|
--signoff::
|
2008-04-26 20:14:28 +00:00
|
|
|
Add Signed-off-by line at the end of the commit message.
|
|
|
|
|
2010-12-11 00:51:44 +00: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.
|
|
|
|
|
2011-08-04 10:39:11 +00:00
|
|
|
SEQUENCER SUBCOMMANDS
|
|
|
|
---------------------
|
|
|
|
include::sequencer.txt[]
|
|
|
|
|
2010-06-02 05:58:41 +00:00
|
|
|
EXAMPLES
|
|
|
|
--------
|
docs: put listed example commands in backticks
Many examples of git command invocation are given in asciidoc listing
blocks, which makes them monospaced and avoids further interpretation of
special characters. Some manpages make a list of examples, like:
git foo::
Run git foo.
git foo -q::
Use the "-q" option.
to quickly show many variants. However, they can sometimes be hard to
read, because they are shown in a proportional-width font (so, for
example, seeing the difference between "-- foo" and "--foo" can be
difficult).
This patch puts all such examples into backticks, which gives the
equivalent formatting to a listing block (i.e., monospaced and without
character interpretation).
As a bonus, this also fixes an example in the git-push manpage, in which
"git push origin :::" was accidentally considered a newly-indented list,
and not a list item with "git push origin :" in it.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-04 02:13:29 +00:00
|
|
|
`git revert HEAD~3`::
|
2010-06-02 05:58:41 +00:00
|
|
|
|
|
|
|
Revert the changes specified by the fourth last commit in HEAD
|
|
|
|
and create a new commit with the reverted changes.
|
|
|
|
|
docs: put listed example commands in backticks
Many examples of git command invocation are given in asciidoc listing
blocks, which makes them monospaced and avoids further interpretation of
special characters. Some manpages make a list of examples, like:
git foo::
Run git foo.
git foo -q::
Use the "-q" option.
to quickly show many variants. However, they can sometimes be hard to
read, because they are shown in a proportional-width font (so, for
example, seeing the difference between "-- foo" and "--foo" can be
difficult).
This patch puts all such examples into backticks, which gives the
equivalent formatting to a listing block (i.e., monospaced and without
character interpretation).
As a bonus, this also fixes an example in the git-push manpage, in which
"git push origin :::" was accidentally considered a newly-indented list,
and not a list item with "git push origin :" in it.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-04 02:13:29 +00:00
|
|
|
`git revert -n master{tilde}5..master{tilde}2`::
|
2010-06-02 05:58:41 +00: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 10:01:09 +00:00
|
|
|
|
2010-06-02 05:58:41 +00:00
|
|
|
SEE ALSO
|
|
|
|
--------
|
|
|
|
linkgit:git-cherry-pick[1]
|
|
|
|
|
2005-08-23 08:49:47 +00:00
|
|
|
GIT
|
|
|
|
---
|
2008-06-06 07:07:32 +00:00
|
|
|
Part of the linkgit:git[1] suite
|