1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE sect2 SYSTEM "../../../dtd/dblite.dtd">
\r
4 <sect2 lang="en" id="git-cherry-pick(1)">
\r
5 <title>git-cherry-pick(1)</title>
\r
7 <primary>git-cherry-pick(1)</primary>
\r
9 <simplesect id="git-cherry-pick(1)__name">
\r
11 <simpara>git-cherry-pick - Apply the changes introduced by some existing commits</simpara>
\r
13 <simplesect id="git-cherry-pick(1)__synopsis">
\r
14 <title>SYNOPSIS</title>
\r
16 <literallayout><emphasis>git cherry-pick</emphasis> [--edit] [-n] [-m parent-number] [-s] [-x] [--ff]
\r
17 [-S[<keyid>]] <commit>…
\r
18 <emphasis>git cherry-pick</emphasis> (--continue | --skip | --abort | --quit)</literallayout>
\r
21 <simplesect id="git-cherry-pick(1)__description">
\r
22 <title>DESCRIPTION</title>
\r
23 <simpara>Given one or more existing commits, apply the change each one
\r
24 introduces, recording a new commit for each. This requires your
\r
25 working tree to be clean (no modifications from the HEAD commit).</simpara>
\r
26 <simpara>When it is not obvious how to apply a change, the following
\r
28 <orderedlist numeration="arabic">
\r
31 The current branch and <emphasis>HEAD</emphasis> pointer stay at the last commit
\r
37 The <emphasis>CHERRY_PICK_HEAD</emphasis> ref is set to point at the commit that
\r
38 introduced the change that is difficult to apply.
\r
43 Paths in which the change applied cleanly are updated both
\r
44 in the index file and in your working tree.
\r
49 For conflicting paths, the index file records up to three
\r
50 versions, as described in the "TRUE MERGE" section of
\r
51 <xref linkend="git-merge(1)" />. The working tree files will include
\r
52 a description of the conflict bracketed by the usual
\r
53 conflict markers <emphasis><<<<<<<</emphasis> and <emphasis>>>>>>>></emphasis>.
\r
58 No other modifications are made.
\r
62 <simpara>See <xref linkend="git-merge(1)" /> for some hints on resolving such
\r
63 conflicts.</simpara>
\r
65 <simplesect id="git-cherry-pick(1)__options">
\r
66 <title>OPTIONS</title>
\r
70 <commit>…
\r
74 Commits to cherry-pick.
\r
75 For a more complete list of ways to spell commits, see
\r
76 <xref linkend="gitrevisions(7)" />.
\r
77 Sets of commits can be passed but no traversal is done by
\r
78 default, as if the <emphasis>--no-walk</emphasis> option was specified, see
\r
79 <xref linkend="git-rev-list(1)" />. Note that specifying a range will
\r
80 feed all <commit>… arguments to a single revision walk
\r
81 (see a later example that uses <emphasis>maint master..next</emphasis>).
\r
94 With this option, <emphasis>git cherry-pick</emphasis> will let you edit the commit
\r
95 message prior to committing.
\r
101 --cleanup=<mode>
\r
105 This option determines how the commit message will be cleaned up before
\r
106 being passed on to the commit machinery. See <xref linkend="git-commit(1)" /> for more
\r
107 details. In particular, if the <emphasis><mode></emphasis> is given a value of <emphasis>scissors</emphasis>,
\r
108 scissors will be appended to <emphasis>MERGE_MSG</emphasis> before being passed on in the case
\r
119 When recording the commit, append a line that says
\r
120 "(cherry picked from commit …)" to the original commit
\r
121 message in order to indicate which commit this change was
\r
122 cherry-picked from. This is done only for cherry
\r
123 picks without conflicts. Do not use this option if
\r
124 you are cherry-picking from your private branch because
\r
125 the information is useless to the recipient. If on the
\r
126 other hand you are cherry-picking between two publicly
\r
127 visible branches (e.g. backporting a fix to a
\r
128 maintenance branch for an older release from a
\r
129 development branch), adding this information can be
\r
140 It used to be that the command defaulted to do <emphasis>-x</emphasis>
\r
141 described above, and <emphasis>-r</emphasis> was to disable it. Now the
\r
142 default is not to do <emphasis>-x</emphasis> so this option is a no-op.
\r
151 --mainline parent-number
\r
155 Usually you cannot cherry-pick a merge because you do not know which
\r
156 side of the merge should be considered the mainline. This
\r
157 option specifies the parent number (starting from 1) of
\r
158 the mainline and allows cherry-pick to replay the change
\r
159 relative to the specified parent.
\r
172 Usually the command automatically creates a sequence of commits.
\r
173 This flag applies the changes necessary to cherry-pick
\r
174 each named commit to your working tree and the index,
\r
175 without making any commit. In addition, when this
\r
176 option is used, your index does not have to match the
\r
177 HEAD commit. The cherry-pick is done against the
\r
178 beginning state of your index.
\r
180 <simpara>This is useful when cherry-picking more than one commits'
\r
181 effect to your index in a row.</simpara>
\r
193 Add Signed-off-by line at the end of the commit message.
\r
194 See the signoff option in <xref linkend="git-commit(1)" /> for more information.
\r
203 --gpg-sign[=<keyid>]
\r
210 GPG-sign commits. The <emphasis>keyid</emphasis> argument is optional and
\r
211 defaults to the committer identity; if specified, it must be
\r
212 stuck to the option without a space. <emphasis>--no-gpg-sign</emphasis> is useful to
\r
213 countermand both <emphasis>commit.gpgSign</emphasis> configuration variable, and
\r
214 earlier <emphasis>--gpg-sign</emphasis>.
\r
224 If the current HEAD is the same as the parent of the
\r
225 cherry-pick'ed commit, then a fast forward to this commit will
\r
236 By default, cherry-picking an empty commit will fail,
\r
237 indicating that an explicit invocation of <emphasis>git commit
\r
238 --allow-empty</emphasis> is required. This option overrides that
\r
239 behavior, allowing empty commits to be preserved automatically
\r
240 in a cherry-pick. Note that when "--ff" is in effect, empty
\r
241 commits that meet the "fast-forward" requirement will be kept
\r
242 even without this option. Note also, that use of this option only
\r
243 keeps commits that were initially empty (i.e. the commit recorded the
\r
244 same tree as its parent). Commits which are made empty due to a
\r
245 previous commit are dropped. To force the inclusion of those commits
\r
246 use <emphasis>--keep-redundant-commits</emphasis>.
\r
252 --allow-empty-message
\r
256 By default, cherry-picking a commit with an empty message will fail.
\r
257 This option overrides that behavior, allowing commits with empty
\r
258 messages to be cherry picked.
\r
264 --keep-redundant-commits
\r
268 If a commit being cherry picked duplicates a commit already in the
\r
269 current history, it will become empty. By default these
\r
270 redundant commits cause <emphasis>cherry-pick</emphasis> to stop so the user can
\r
271 examine the commit. This option overrides that behavior and
\r
272 creates an empty commit object. Implies <emphasis>--allow-empty</emphasis>.
\r
278 --strategy=<strategy>
\r
282 Use the given merge strategy. Should only be used once.
\r
283 See the MERGE STRATEGIES section in <xref linkend="git-merge(1)" />
\r
293 --strategy-option=<option>
\r
297 Pass the merge strategy-specific option through to the
\r
298 merge strategy. See <xref linkend="git-merge(1)" /> for details.
\r
304 --rerere-autoupdate
\r
307 --no-rerere-autoupdate
\r
311 Allow the rerere mechanism to update the index with the
\r
312 result of auto-conflict resolution if possible.
\r
318 <simplesect id="git-cherry-pick(1)__sequencer_subcommands">
\r
319 <title>SEQUENCER SUBCOMMANDS</title>
\r
327 Continue the operation in progress using the information in
\r
328 <emphasis>.git/sequencer</emphasis>. Can be used to continue after resolving
\r
329 conflicts in a failed cherry-pick or revert.
\r
339 Skip the current commit and continue with the rest of the
\r
350 Forget about the current operation in progress. Can be used
\r
351 to clear the sequencer state after a failed cherry-pick or
\r
362 Cancel the operation and return to the pre-sequence state.
\r
368 <simplesect id="git-cherry-pick(1)__examples">
\r
369 <title>EXAMPLES</title>
\r
373 <emphasis>git cherry-pick master</emphasis>
\r
377 Apply the change introduced by the commit at the tip of the
\r
378 master branch and create a new commit with this change.
\r
384 <emphasis>git cherry-pick ..master</emphasis>
\r
387 <emphasis>git cherry-pick ^HEAD master</emphasis>
\r
391 Apply the changes introduced by all commits that are ancestors
\r
392 of master but not of HEAD to produce new commits.
\r
398 <emphasis>git cherry-pick maint next ^master</emphasis>
\r
401 <emphasis>git cherry-pick maint master..next</emphasis>
\r
405 Apply the changes introduced by all commits that are
\r
406 ancestors of maint or next, but not master or any of its
\r
407 ancestors. Note that the latter does not mean <emphasis>maint</emphasis> and
\r
408 everything between <emphasis>master</emphasis> and <emphasis>next</emphasis>; specifically,
\r
409 <emphasis>maint</emphasis> will not be used if it is included in <emphasis>master</emphasis>.
\r
415 <emphasis>git cherry-pick master~4 master~2</emphasis>
\r
419 Apply the changes introduced by the fifth and third last
\r
420 commits pointed to by master and create 2 new commits with
\r
427 <emphasis>git cherry-pick -n master~1 next</emphasis>
\r
431 Apply to the working tree and the index the changes introduced
\r
432 by the second last commit pointed to by master and by the last
\r
433 commit pointed to by next, but do not create any commit with
\r
440 <emphasis>git cherry-pick --ff ..next</emphasis>
\r
444 If history is linear and HEAD is an ancestor of next, update
\r
445 the working tree and advance the HEAD pointer to match next.
\r
446 Otherwise, apply the changes introduced by those commits that
\r
447 are in next but not HEAD to the current branch, creating a new
\r
448 commit for each new change.
\r
454 <emphasis>git rev-list --reverse master -- README | git cherry-pick -n --stdin</emphasis>
\r
458 Apply the changes introduced by all commits on the master
\r
459 branch that touched README to the working tree and index,
\r
460 so the result can be inspected and made into a single new
\r
461 commit if suitable.
\r
466 <simpara>The following sequence attempts to backport a patch, bails out because
\r
467 the code the patch applies to has changed too much, and then tries
\r
468 again, this time exercising more care about matching up context lines.</simpara>
\r
469 <screen>$ git cherry-pick topic^ <co id="git-cherry-pick_CO1-1"/>
\r
470 $ git diff <co id="git-cherry-pick_CO1-2"/>
\r
471 $ git reset --merge ORIG_HEAD <co id="git-cherry-pick_CO1-3"/>
\r
472 $ git cherry-pick -Xpatience topic^ <co id="git-cherry-pick_CO1-4"/></screen>
\r
474 <callout arearefs="git-cherry-pick_CO1-1">
\r
476 apply the change that would be shown by <emphasis>git show topic^</emphasis>.
\r
477 In this example, the patch does not apply cleanly, so
\r
478 information about the conflict is written to the index and
\r
479 working tree and no new commit results.
\r
482 <callout arearefs="git-cherry-pick_CO1-2">
\r
484 summarize changes to be reconciled
\r
487 <callout arearefs="git-cherry-pick_CO1-3">
\r
489 cancel the cherry-pick. In other words, return to the
\r
490 pre-cherry-pick state, preserving any local modifications
\r
491 you had in the working tree.
\r
494 <callout arearefs="git-cherry-pick_CO1-4">
\r
496 try to apply the change introduced by <emphasis>topic^</emphasis> again,
\r
497 spending extra time to avoid mistakes based on incorrectly
\r
498 matching context lines.
\r
503 <simplesect id="git-cherry-pick(1)__see_also">
\r
504 <title>SEE ALSO</title>
\r
505 <simpara><xref linkend="git-revert(1)" /></simpara>
\r
507 <simplesect id="git-cherry-pick(1)__git">
\r
509 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
\r