Home Explore Blog CI



git

1st chunk of `Documentation/git-revert.adoc`
8c3f5f7408d7a28c0dc60f46dc03da7a125235cab1a811d30000000100000a9b
git-revert(1)
=============

NAME
----
git-revert - Revert some existing commits

SYNOPSIS
--------
[verse]
'git revert' [--[no-]edit] [-n] [-m <parent-number>] [-s] [-S[<keyid>]] <commit>...
'git revert' (--continue | --skip | --abort | --quit)

DESCRIPTION
-----------

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
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
should see linkgit:git-restore[1], specifically the `--source`
option. Take care with these alternatives as
both will discard uncommitted changes in your working directory.

See "Reset, restore and revert" in linkgit:git[1] for the differences
between the three commands.

OPTIONS
-------
<commit>...::
	Commits to revert.
	For a more complete list of ways to spell commit names, see
	linkgit:gitrevisions[7].
	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.

-e::
--edit::
	With this option, 'git revert' will let you edit the commit
	message prior to committing the revert. This is the default if
	you run the command from a terminal.

-m parent-number::
--mainline parent-number::
	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.
+
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.html[revert-a-faulty-merge How-To] for
more details.

--no-edit::
	With this option, 'git revert' will not start the commit
	message editor.

--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.

-n::
--no-commit::
	Usually the

Title: Git Revert Command
Summary
The git-revert command is used to reverse the changes made by one or more existing commits, creating new commits to record the reversal, while requiring a clean working tree and providing various options for customization and conflict resolution.