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
|
docs: stop using asciidoc no-inline-literal
In asciidoc 7, backticks like `foo` produced a typographic
effect, but did not otherwise affect the syntax. In asciidoc
8, backticks introduce an "inline literal" inside which markup
is not interpreted. To keep compatibility with existing
documents, asciidoc 8 has a "no-inline-literal" attribute to
keep the old behavior. We enabled this so that the
documentation could be built on either version.
It has been several years now, and asciidoc 7 is no longer
in wide use. We can now decide whether or not we want
inline literals on their own merits, which are:
1. The source is much easier to read when the literal
contains punctuation. You can use `master~1` instead
of `master{tilde}1`.
2. They are less error-prone. Because of point (1), we
tend to make mistakes and forget the extra layer of
quoting.
This patch removes the no-inline-literal attribute from the
Makefile and converts every use of backticks in the
documentation to an inline literal (they must be cleaned up,
or the example above would literally show "{tilde}" in the
output).
Problematic sites were found by grepping for '`.*[{\\]' and
examined and fixed manually. The results were then verified
by comparing the output of "html2text" on the set of
generated html pages. Doing so revealed that in addition to
making the source more readable, this patch fixes several
formatting bugs:
- HTML rendering used the ellipsis character instead of
literal "..." in code examples (like "git log A...B")
- some code examples used the right-arrow character
instead of '->' because they failed to quote
- api-config.txt did not quote tilde, and the resulting
HTML contained a bogus snippet like:
<tt><sub></tt> foo <tt></sub>bar</tt>
which caused some parsers to choke and omit whole
sections of the page.
- git-commit.txt confused ``foo`` (backticks inside a
literal) with ``foo'' (matched double-quotes)
- mentions of `A U Thor <author@example.com>` used to
erroneously auto-generate a mailto footnote for
author@example.com
- the description of --word-diff=plain incorrectly showed
the output as "[-removed-] and {added}", not "{+added+}".
- using "prime" notation like:
commit `C` and its replacement `C'`
confused asciidoc into thinking that everything between
the first backtick and the final apostrophe were meant
to be inside matched quotes
- asciidoc got confused by the escaping of some of our
asterisks. In particular,
`credential.\*` and `credential.<url>.\*`
properly escaped the asterisk in the first case, but
literally passed through the backslash in the second
case.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-26 08:51:57 +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: stop using asciidoc no-inline-literal
In asciidoc 7, backticks like `foo` produced a typographic
effect, but did not otherwise affect the syntax. In asciidoc
8, backticks introduce an "inline literal" inside which markup
is not interpreted. To keep compatibility with existing
documents, asciidoc 8 has a "no-inline-literal" attribute to
keep the old behavior. We enabled this so that the
documentation could be built on either version.
It has been several years now, and asciidoc 7 is no longer
in wide use. We can now decide whether or not we want
inline literals on their own merits, which are:
1. The source is much easier to read when the literal
contains punctuation. You can use `master~1` instead
of `master{tilde}1`.
2. They are less error-prone. Because of point (1), we
tend to make mistakes and forget the extra layer of
quoting.
This patch removes the no-inline-literal attribute from the
Makefile and converts every use of backticks in the
documentation to an inline literal (they must be cleaned up,
or the example above would literally show "{tilde}" in the
output).
Problematic sites were found by grepping for '`.*[{\\]' and
examined and fixed manually. The results were then verified
by comparing the output of "html2text" on the set of
generated html pages. Doing so revealed that in addition to
making the source more readable, this patch fixes several
formatting bugs:
- HTML rendering used the ellipsis character instead of
literal "..." in code examples (like "git log A...B")
- some code examples used the right-arrow character
instead of '->' because they failed to quote
- api-config.txt did not quote tilde, and the resulting
HTML contained a bogus snippet like:
<tt><sub></tt> foo <tt></sub>bar</tt>
which caused some parsers to choke and omit whole
sections of the page.
- git-commit.txt confused ``foo`` (backticks inside a
literal) with ``foo'' (matched double-quotes)
- mentions of `A U Thor <author@example.com>` used to
erroneously auto-generate a mailto footnote for
author@example.com
- the description of --word-diff=plain incorrectly showed
the output as "[-removed-] and {added}", not "{+added+}".
- using "prime" notation like:
commit `C` and its replacement `C'`
confused asciidoc into thinking that everything between
the first backtick and the final apostrophe were meant
to be inside matched quotes
- asciidoc got confused by the escaping of some of our
asterisks. In particular,
`credential.\*` and `credential.<url>.\*`
properly escaped the asterisk in the first case, but
literally passed through the backslash in the second
case.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-26 08:51:57 +00:00
|
|
|
`git revert -n master~5..master~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
|