Skip to content

Commit 8c7da86

Browse files
committed
Merge branch 'cc/cherry-pick-series'
* cc/cherry-pick-series: Documentation/revert: describe passing more than one commit Documentation/cherry-pick: describe passing more than one commit revert: add tests to check cherry-picking many commits revert: allow cherry-picking more than one commit revert: change help_msg() to take no argument revert: refactor code into a do_pick_commit() function revert: use run_command_v_opt() instead of execv_git_cmd() revert: cleanup code for -x option
2 parents a214afd + 86c7bb4 commit 8c7da86

File tree

4 files changed

+264
-66
lines changed

4 files changed

+264
-66
lines changed

Documentation/git-cherry-pick.txt

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,28 @@ git-cherry-pick(1)
33

44
NAME
55
----
6-
git-cherry-pick - Apply the change introduced by an existing commit
6+
git-cherry-pick - Apply the changes introduced by some existing commits
77

88
SYNOPSIS
99
--------
10-
'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>
10+
'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>...
1111

1212
DESCRIPTION
1313
-----------
14-
Given one existing commit, apply 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).
14+
15+
Given one or more existing commits, apply the change each one
16+
introduces, recording a new commit for each. This requires your
17+
working tree to be clean (no modifications from the HEAD commit).
1718

1819
OPTIONS
1920
-------
20-
<commit>::
21-
Commit to cherry-pick.
21+
<commit>...::
22+
Commits to cherry-pick.
2223
For a more complete list of ways to spell commits, see the
2324
"SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1].
25+
Sets of commits can be passed but no traversal is done by
26+
default, as if the '--no-walk' option was specified, see
27+
linkgit:git-rev-list[1].
2428

2529
-e::
2630
--edit::
@@ -55,10 +59,10 @@ OPTIONS
5559

5660
-n::
5761
--no-commit::
58-
Usually the command automatically creates a commit.
59-
This flag applies the change necessary to cherry-pick
60-
the named commit to your working tree and the index,
61-
but does not make the commit. In addition, when this
62+
Usually the command automatically creates a sequence of commits.
63+
This flag applies the changes necessary to cherry-pick
64+
each named commit to your working tree and the index,
65+
without making any commit. In addition, when this
6266
option is used, your index does not have to match the
6367
HEAD commit. The cherry-pick is done against the
6468
beginning state of your index.
@@ -75,6 +79,40 @@ effect to your index in a row.
7579
cherry-pick'ed commit, then a fast forward to this commit will
7680
be performed.
7781

82+
EXAMPLES
83+
--------
84+
git cherry-pick master::
85+
86+
Apply the change introduced by the commit at the tip of the
87+
master branch and create a new commit with this change.
88+
89+
git cherry-pick ..master::
90+
git cherry-pick ^HEAD master::
91+
92+
Apply the changes introduced by all commits that are ancestors
93+
of master but not of HEAD to produce new commits.
94+
95+
git cherry-pick master\~4 master~2::
96+
97+
Apply the changes introduced by the fifth and third last
98+
commits pointed to by master and create 2 new commits with
99+
these changes.
100+
101+
git cherry-pick -n master~1 next::
102+
103+
Apply to the working tree and the index the changes introduced
104+
by the second last commit pointed to by master and by the last
105+
commit pointed to by next, but do not create any commit with
106+
these changes.
107+
108+
git cherry-pick --ff ..next::
109+
110+
If history is linear and HEAD is an ancestor of next, update
111+
the working tree and advance the HEAD pointer to match next.
112+
Otherwise, apply the changes introduced by those commits that
113+
are in next but not HEAD to the current branch, creating a new
114+
commit for each new change.
115+
78116
Author
79117
------
80118
Written by Junio C Hamano <gitster@pobox.com>
@@ -83,6 +121,10 @@ Documentation
83121
--------------
84122
Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
85123

124+
SEE ALSO
125+
--------
126+
linkgit:git-revert[1]
127+
86128
GIT
87129
---
88130
Part of the linkgit:git[1] suite

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 <git@vger.kernel.org>.
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)