Skip to content

Commit b98878e

Browse files
carlosmngitster
authored andcommitted
git-cherry-pick.txt: clarify the use of revision range notation
When given a set of commits, cherry-pick will apply the changes for all of them. Specifying a simple range will also work as expected. This can lead the user to think that git cherry-pick A B..C may apply A and then B..C, but that is not what happens. Instead the revs are given to a single invocation of rev-list, which will consider A and C as positive revs and B as a negative one. The commit A will not be used if it is an ancestor of B. Add a note about this and add an example with this particular syntax, which has shown up on the list a few times. Signed-off-by: Carlos Martín Nieto <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 42939f1 commit b98878e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Documentation/git-cherry-pick.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ OPTIONS
4747
linkgit:gitrevisions[7].
4848
Sets of commits can be passed but no traversal is done by
4949
default, as if the '--no-walk' option was specified, see
50-
linkgit:git-rev-list[1].
50+
linkgit:git-rev-list[1]. Note that specifying a range will
51+
feed all <commit>... arguments to a single revision walk
52+
(see a later example that uses 'maint master..next').
5153

5254
-e::
5355
--edit::
@@ -130,6 +132,15 @@ EXAMPLES
130132
Apply the changes introduced by all commits that are ancestors
131133
of master but not of HEAD to produce new commits.
132134

135+
`git cherry-pick maint next ^master`::
136+
`git cherry-pick maint master..next`::
137+
138+
Apply the changes introduced by all commits that are
139+
ancestors of maint or next, but not master or any of its
140+
ancestors. Note that the latter does not mean `maint` and
141+
everything between `master` and `next`; specifically,
142+
`maint` will not be used if it is included in `master`.
143+
133144
`git cherry-pick master{tilde}4 master{tilde}2`::
134145

135146
Apply the changes introduced by the fifth and third last

0 commit comments

Comments
 (0)