Skip to content

Commit 89d32d3

Browse files
chriscoolgitster
authored andcommitted
Documentation/cherry-pick: 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 aa29ccf commit 89d32d3

File tree

1 file changed

+53
-11
lines changed

1 file changed

+53
-11
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 <[email protected]>
@@ -83,6 +121,10 @@ Documentation
83121
--------------
84122
Documentation by Junio C Hamano and the git-list <[email protected]>.
85123

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

0 commit comments

Comments
 (0)