Skip to content

Commit 86c7bb4

Browse files
chriscoolgitster
authored andcommitted
Documentation/revert: describe passing more than one commit
And while at it, add an "EXAMPLES" section. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 89d32d3 commit 86c7bb4

File tree

1 file changed

+37
-14
lines changed

1 file changed

+37
-14
lines changed

Documentation/git-revert.txt

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@ git-revert(1)
33

44
NAME
55
----
6-
git-revert - Revert an existing commit
6+
git-revert - Revert some existing commits
77

88
SYNOPSIS
99
--------
10-
'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>
10+
'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>...
1111

1212
DESCRIPTION
1313
-----------
14-
Given one existing commit, revert the change the patch introduces, and record a
15-
new commit that records it. This requires your working tree to be clean (no
16-
modifications from the HEAD commit).
1714

18-
Note: 'git revert' is used to record a new commit to reverse the
19-
effect of an earlier commit (often a faulty one). If you want to
15+
Given one or more existing commits, revert the changes that the
16+
related patches introduce, and record some new commits that record
17+
them. This requires your working tree to be clean (no modifications
18+
from the HEAD commit).
19+
20+
Note: 'git revert' is used to record some new commits to reverse the
21+
effect of some earlier commits (often only a faulty one). If you want to
2022
throw away all uncommitted changes in your working directory, you
2123
should see linkgit:git-reset[1], particularly the '--hard' option. If
2224
you want to extract specific files as they were in another commit, you
@@ -26,10 +28,13 @@ both will discard uncommitted changes in your working directory.
2628

2729
OPTIONS
2830
-------
29-
<commit>::
30-
Commit to revert.
31+
<commit>...::
32+
Commits to revert.
3133
For a more complete list of ways to spell commit names, see
3234
"SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1].
35+
Sets of commits can also be given but no traversal is done by
36+
default, see linkgit:git-rev-list[1] and its '--no-walk'
37+
option.
3338

3439
-e::
3540
--edit::
@@ -59,11 +64,11 @@ more details.
5964

6065
-n::
6166
--no-commit::
62-
Usually the command automatically creates a commit with
63-
a commit log message stating which commit was
64-
reverted. This flag applies the change necessary
65-
to revert the named commit to your working tree
66-
and the index, but does not make the commit. In addition,
67+
Usually the command automatically creates some commits with
68+
commit log messages stating which commits were
69+
reverted. This flag applies the changes necessary
70+
to revert the named commits to your working tree
71+
and the index, but does not make the commits. In addition,
6772
when this option is used, your index does not have to match
6873
the HEAD commit. The revert is done against the
6974
beginning state of your index.
@@ -75,6 +80,20 @@ effect to your index in a row.
7580
--signoff::
7681
Add Signed-off-by line at the end of the commit message.
7782

83+
EXAMPLES
84+
--------
85+
git revert HEAD~3::
86+
87+
Revert the changes specified by the fourth last commit in HEAD
88+
and create a new commit with the reverted changes.
89+
90+
git revert -n master\~5..master~2::
91+
92+
Revert the changes done by commits from the fifth last commit
93+
in master (included) to the third last commit in master
94+
(included), but do not create any commit with the reverted
95+
changes. The revert only modifies the working tree and the
96+
index.
7897

7998
Author
8099
------
@@ -84,6 +103,10 @@ Documentation
84103
--------------
85104
Documentation by Junio C Hamano and the git-list <[email protected]>.
86105

106+
SEE ALSO
107+
--------
108+
linkgit:git-cherry-pick[1]
109+
87110
GIT
88111
---
89112
Part of the linkgit:git[1] suite

0 commit comments

Comments
 (0)