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
|
|
|
|
--------
|
2011-07-02 04:38:26 +02:00
|
|
|
[verse]
|
2015-09-19 09:47:48 +02:00
|
|
|
'git revert' [--[no-]edit] [-n] [-m parent-number] [-s] [-S[<keyid>]] <commit>...
|
2019-07-02 11:11:28 +02:00
|
|
|
'git revert' (--continue | --skip | --abort | --quit)
|
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
|
2016-06-28 13:40:11 +02:00
|
|
|
should see linkgit:git-reset[1], particularly the `--hard` option. If
|
2008-08-19 21:50:31 +02:00
|
|
|
you want to extract specific files as they were in another commit, you
|
2019-04-25 11:45:58 +02:00
|
|
|
should see linkgit:git-restore[1], specifically the `--source`
|
|
|
|
option. Take care with these alternatives as
|
2008-08-19 21:50:31 +02:00
|
|
|
both will discard uncommitted changes in your working directory.
|
|
|
|
|
2019-04-25 11:45:45 +02:00
|
|
|
See "Reset, restore and revert" in linkgit:git[1] for the differences
|
|
|
|
between the three commands.
|
|
|
|
|
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
|
2016-06-28 13:40:11 +02:00
|
|
|
default, see linkgit:git-rev-list[1] and its `--no-walk`
|
2010-06-02 07:58:41 +02:00
|
|
|
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.
|
|
|
|
+
|
2013-09-06 22:03:22 +02:00
|
|
|
See the link:howto/revert-a-faulty-merge.html[revert-a-faulty-merge How-To] for
|
2008-12-22 01:26:03 +01:00
|
|
|
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.
|
|
|
|
|
2019-04-17 12:23:30 +02:00
|
|
|
--cleanup=<mode>::
|
|
|
|
This option determines how the commit message will be cleaned up before
|
|
|
|
being passed on to the commit machinery. See linkgit:git-commit[1] for more
|
|
|
|
details. In particular, if the '<mode>' is given a value of `scissors`,
|
|
|
|
scissors will be appended to `MERGE_MSG` before being passed on in the case
|
|
|
|
of a conflict.
|
|
|
|
|
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
|
|
|
|
2015-09-19 09:47:48 +02:00
|
|
|
-S[<keyid>]::
|
|
|
|
--gpg-sign[=<keyid>]::
|
2020-04-03 12:28:03 +02:00
|
|
|
--no-gpg-sign::
|
2015-09-19 09:47:50 +02:00
|
|
|
GPG-sign commits. The `keyid` argument is optional and
|
|
|
|
defaults to the committer identity; if specified, it must be
|
2020-04-03 12:28:03 +02:00
|
|
|
stuck to the option without a space. `--no-gpg-sign` is useful to
|
|
|
|
countermand both `commit.gpgSign` configuration variable, and
|
|
|
|
earlier `--gpg-sign`.
|
2014-01-24 01:50:58 +01: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.
|
2016-01-05 20:20:26 +01:00
|
|
|
See the signoff option in linkgit:git-commit[1] for more information.
|
2008-04-26 22:14:28 +02:00
|
|
|
|
2010-12-11 01:51:44 +01: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.
|
|
|
|
|
2019-03-14 20:12:32 +01:00
|
|
|
--rerere-autoupdate::
|
|
|
|
--no-rerere-autoupdate::
|
|
|
|
Allow the rerere mechanism to update the index with the
|
|
|
|
result of auto-conflict resolution if possible.
|
|
|
|
|
2011-08-04 12:39:11 +02:00
|
|
|
SEQUENCER SUBCOMMANDS
|
|
|
|
---------------------
|
|
|
|
include::sequencer.txt[]
|
|
|
|
|
2010-06-02 07:58:41 +02: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 04:13:29 +02:00
|
|
|
`git revert HEAD~3`::
|
2010-06-02 07:58:41 +02: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 10:51:57 +02:00
|
|
|
`git revert -n master~5..master~2`::
|
2010-06-02 07:58:41 +02: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 12:01:09 +02:00
|
|
|
|
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
|