6 git-cherry-pick - Apply the changes introduced by some existing commits
10 'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>...
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).
22 Commits to cherry-pick.
23 For a more complete list of ways to spell commits, see
24 linkgit:gitrevisions[7].
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].
31 With this option, 'git cherry-pick' will let you edit the commit
32 message prior to committing.
35 When recording the commit, append a line that says
36 "(cherry picked from commit ...)" to the original commit
37 message in order to indicate which commit this change was
38 cherry-picked from. This is done only for cherry
39 picks without conflicts. Do not use this option if
40 you are cherry-picking from your private branch because
41 the information is useless to the recipient. If on the
42 other hand you are cherry-picking between two publicly
43 visible branches (e.g. backporting a fix to a
44 maintenance branch for an older release from a
45 development branch), adding this information can be
49 It used to be that the command defaulted to do `-x`
50 described above, and `-r` was to disable it. Now the
51 default is not to do `-x` so this option is a no-op.
54 --mainline parent-number::
55 Usually you cannot cherry-pick a merge because you do not know which
56 side of the merge should be considered the mainline. This
57 option specifies the parent number (starting from 1) of
58 the mainline and allows cherry-pick to replay the change
59 relative to the specified parent.
63 Usually the command automatically creates a sequence of commits.
64 This flag applies the changes necessary to cherry-pick
65 each named commit to your working tree and the index,
66 without making any commit. In addition, when this
67 option is used, your index does not have to match the
68 HEAD commit. The cherry-pick is done against the
69 beginning state of your index.
71 This is useful when cherry-picking more than one commits'
72 effect to your index in a row.
76 Add Signed-off-by line at the end of the commit message.
79 If the current HEAD is the same as the parent of the
80 cherry-pick'ed commit, then a fast forward to this commit will
85 git cherry-pick master::
87 Apply the change introduced by the commit at the tip of the
88 master branch and create a new commit with this change.
90 git cherry-pick ..master::
91 git cherry-pick ^HEAD master::
93 Apply the changes introduced by all commits that are ancestors
94 of master but not of HEAD to produce new commits.
96 git cherry-pick master{tilde}4 master{tilde}2::
98 Apply the changes introduced by the fifth and third last
99 commits pointed to by master and create 2 new commits with
102 git cherry-pick -n master~1 next::
104 Apply to the working tree and the index the changes introduced
105 by the second last commit pointed to by master and by the last
106 commit pointed to by next, but do not create any commit with
109 git cherry-pick --ff ..next::
111 If history is linear and HEAD is an ancestor of next, update
112 the working tree and advance the HEAD pointer to match next.
113 Otherwise, apply the changes introduced by those commits that
114 are in next but not HEAD to the current branch, creating a new
115 commit for each new change.
117 git rev-list --reverse master \-- README | git cherry-pick -n --stdin::
119 Apply the changes introduced by all commits on the master
120 branch that touched README to the working tree and index,
121 so the result can be inspected and made into a single new
126 Written by Junio C Hamano <gitster@pobox.com>
130 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
134 linkgit:git-revert[1]
138 Part of the linkgit:git[1] suite