1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
\r
4 <article lang="en" id="git-cherry-pick(1)">
\r
6 <title>git-cherry-pick(1)</title>
\r
8 <primary>git-cherry-pick(1)</primary>
\r
11 <simplesect id="_name">
\r
13 <simpara>git-cherry-pick - Apply the changes introduced by some existing commits</simpara>
\r
15 <simplesect id="_synopsis">
\r
16 <title>SYNOPSIS</title>
\r
18 <literallayout><emphasis>git cherry-pick</emphasis> [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>…
\r
19 <emphasis>git cherry-pick</emphasis> --continue
\r
20 <emphasis>git cherry-pick</emphasis> --quit
\r
21 <emphasis>git cherry-pick</emphasis> --abort</literallayout>
\r
24 <simplesect id="_description">
\r
25 <title>DESCRIPTION</title>
\r
26 <simpara>Given one or more existing commits, apply the change each one
\r
27 introduces, recording a new commit for each. This requires your
\r
28 working tree to be clean (no modifications from the HEAD commit).</simpara>
\r
29 <simpara>When it is not obvious how to apply a change, the following
\r
31 <orderedlist numeration="arabic">
\r
34 The current branch and <emphasis>HEAD</emphasis> pointer stay at the last commit
\r
40 The <emphasis>CHERRY_PICK_HEAD</emphasis> ref is set to point at the commit that
\r
41 introduced the change that is difficult to apply.
\r
46 Paths in which the change applied cleanly are updated both
\r
47 in the index file and in your working tree.
\r
52 For conflicting paths, the index file records up to three
\r
53 versions, as described in the "TRUE MERGE" section of
\r
54 <xref linkend="git-merge(1)" />. The working tree files will include
\r
55 a description of the conflict bracketed by the usual
\r
56 conflict markers <emphasis><<<<<<<</emphasis> and <emphasis>>>>>>>></emphasis>.
\r
61 No other modifications are made.
\r
65 <simpara>See <xref linkend="git-merge(1)" /> for some hints on resolving such
\r
66 conflicts.</simpara>
\r
68 <simplesect id="_options">
\r
69 <title>OPTIONS</title>
\r
73 <commit>…
\r
77 Commits to cherry-pick.
\r
78 For a more complete list of ways to spell commits, see
\r
79 <xref linkend="gitrevisions(7)" />.
\r
80 Sets of commits can be passed but no traversal is done by
\r
81 default, as if the <emphasis>--no-walk</emphasis> option was specified, see
\r
82 <xref linkend="git-rev-list(1)" />.
\r
95 With this option, <emphasis>git cherry-pick</emphasis> will let you edit the commit
\r
96 message prior to committing.
\r
106 When recording the commit, append a line that says
\r
107 "(cherry picked from commit …)" to the original commit
\r
108 message in order to indicate which commit this change was
\r
109 cherry-picked from. This is done only for cherry
\r
110 picks without conflicts. Do not use this option if
\r
111 you are cherry-picking from your private branch because
\r
112 the information is useless to the recipient. If on the
\r
113 other hand you are cherry-picking between two publicly
\r
114 visible branches (e.g. backporting a fix to a
\r
115 maintenance branch for an older release from a
\r
116 development branch), adding this information can be
\r
127 It used to be that the command defaulted to do <emphasis>-x</emphasis>
\r
128 described above, and <emphasis>-r</emphasis> was to disable it. Now the
\r
129 default is not to do <emphasis>-x</emphasis> so this option is a no-op.
\r
138 --mainline parent-number
\r
142 Usually you cannot cherry-pick a merge because you do not know which
\r
143 side of the merge should be considered the mainline. This
\r
144 option specifies the parent number (starting from 1) of
\r
145 the mainline and allows cherry-pick to replay the change
\r
146 relative to the specified parent.
\r
159 Usually the command automatically creates a sequence of commits.
\r
160 This flag applies the changes necessary to cherry-pick
\r
161 each named commit to your working tree and the index,
\r
162 without making any commit. In addition, when this
\r
163 option is used, your index does not have to match the
\r
164 HEAD commit. The cherry-pick is done against the
\r
165 beginning state of your index.
\r
167 <simpara>This is useful when cherry-picking more than one commits'
\r
168 effect to your index in a row.</simpara>
\r
180 Add Signed-off-by line at the end of the commit message.
\r
190 If the current HEAD is the same as the parent of the
\r
191 cherry-pick'ed commit, then a fast forward to this commit will
\r
198 --strategy=<strategy>
\r
202 Use the given merge strategy. Should only be used once.
\r
203 See the MERGE STRATEGIES section in <xref linkend="git-merge(1)" />
\r
213 --strategy-option=<option>
\r
217 Pass the merge strategy-specific option through to the
\r
218 merge strategy. See <xref linkend="git-merge(1)" /> for details.
\r
224 <simplesect id="_sequencer_subcommands">
\r
225 <title>SEQUENCER SUBCOMMANDS</title>
\r
233 Continue the operation in progress using the information in
\r
234 <emphasis>.git/sequencer</emphasis>. Can be used to continue after resolving
\r
235 conflicts in a failed cherry-pick or revert.
\r
245 Forget about the current operation in progress. Can be used
\r
246 to clear the sequencer state after a failed cherry-pick or
\r
257 Cancel the operation and return to the pre-sequence state.
\r
263 <simplesect id="_examples">
\r
264 <title>EXAMPLES</title>
\r
268 <emphasis>git cherry-pick master</emphasis>
\r
272 Apply the change introduced by the commit at the tip of the
\r
273 master branch and create a new commit with this change.
\r
279 <emphasis>git cherry-pick ..master</emphasis>
\r
282 <emphasis>git cherry-pick ^HEAD master</emphasis>
\r
286 Apply the changes introduced by all commits that are ancestors
\r
287 of master but not of HEAD to produce new commits.
\r
293 <emphasis>git cherry-pick master~4 master~2</emphasis>
\r
297 Apply the changes introduced by the fifth and third last
\r
298 commits pointed to by master and create 2 new commits with
\r
305 <emphasis>git cherry-pick -n master~1 next</emphasis>
\r
309 Apply to the working tree and the index the changes introduced
\r
310 by the second last commit pointed to by master and by the last
\r
311 commit pointed to by next, but do not create any commit with
\r
318 <emphasis>git cherry-pick --ff ..next</emphasis>
\r
322 If history is linear and HEAD is an ancestor of next, update
\r
323 the working tree and advance the HEAD pointer to match next.
\r
324 Otherwise, apply the changes introduced by those commits that
\r
325 are in next but not HEAD to the current branch, creating a new
\r
326 commit for each new change.
\r
332 <emphasis>git rev-list --reverse master -- README | git cherry-pick -n --stdin</emphasis>
\r
336 Apply the changes introduced by all commits on the master
\r
337 branch that touched README to the working tree and index,
\r
338 so the result can be inspected and made into a single new
\r
339 commit if suitable.
\r
344 <simpara>The following sequence attempts to backport a patch, bails out because
\r
345 the code the patch applies to has changed too much, and then tries
\r
346 again, this time exercising more care about matching up context lines.</simpara>
\r
347 <screen>$ git cherry-pick topic^ <co id="CO1-1"/>
\r
348 $ git diff <co id="CO1-2"/>
\r
349 $ git reset --merge ORIG_HEAD <co id="CO1-3"/>
\r
350 $ git cherry-pick -Xpatience topic^ <co id="CO1-4"/></screen>
\r
352 <callout arearefs="CO1-1">
\r
354 apply the change that would be shown by <emphasis>git show topic^</emphasis>.
\r
355 In this example, the patch does not apply cleanly, so
\r
356 information about the conflict is written to the index and
\r
357 working tree and no new commit results.
\r
360 <callout arearefs="CO1-2">
\r
362 summarize changes to be reconciled
\r
365 <callout arearefs="CO1-3">
\r
367 cancel the cherry-pick. In other words, return to the
\r
368 pre-cherry-pick state, preserving any local modifications you had in
\r
372 <callout arearefs="CO1-4">
\r
374 try to apply the change introduced by <emphasis>topic^</emphasis> again,
\r
375 spending extra time to avoid mistakes based on incorrectly matching
\r
381 <simplesect id="_see_also">
\r
382 <title>SEE ALSO</title>
\r
383 <simpara><xref linkend="git-revert(1)" /></simpara>
\r
385 <simplesect id="_git">
\r
387 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
\r