revert: Introduce --continue to continue the operation
[git/jnareb-git.git] / Documentation / git-cherry-pick.txt
blob663186bda747ce02af4b5ca1732254a0e2425369
1 git-cherry-pick(1)
2 ==================
4 NAME
5 ----
6 git-cherry-pick - Apply the changes introduced by some existing commits
8 SYNOPSIS
9 --------
10 'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>...
11 'git cherry-pick' --reset
12 'git cherry-pick' --continue
14 DESCRIPTION
15 -----------
17 Given one or more existing commits, apply the change each one
18 introduces, recording a new commit for each.  This requires your
19 working tree to be clean (no modifications from the HEAD commit).
21 When it is not obvious how to apply a change, the following
22 happens:
24 1. The current branch and `HEAD` pointer stay at the last commit
25    successfully made.
26 2. The `CHERRY_PICK_HEAD` ref is set to point at the commit that
27    introduced the change that is difficult to apply.
28 3. Paths in which the change applied cleanly are updated both
29    in the index file and in your working tree.
30 4. For conflicting paths, the index file records up to three
31    versions, as described in the "TRUE MERGE" section of
32    linkgit:git-merge[1].  The working tree files will include
33    a description of the conflict bracketed by the usual
34    conflict markers `<<<<<<<` and `>>>>>>>`.
35 5. No other modifications are made.
37 See linkgit:git-merge[1] for some hints on resolving such
38 conflicts.
40 OPTIONS
41 -------
42 <commit>...::
43         Commits to cherry-pick.
44         For a more complete list of ways to spell commits, see
45         linkgit:gitrevisions[7].
46         Sets of commits can be passed but no traversal is done by
47         default, as if the '--no-walk' option was specified, see
48         linkgit:git-rev-list[1].
50 -e::
51 --edit::
52         With this option, 'git cherry-pick' will let you edit the commit
53         message prior to committing.
55 -x::
56         When recording the commit, append a line that says
57         "(cherry picked from commit ...)" to the original commit
58         message in order to indicate which commit this change was
59         cherry-picked from.  This is done only for cherry
60         picks without conflicts.  Do not use this option if
61         you are cherry-picking from your private branch because
62         the information is useless to the recipient.  If on the
63         other hand you are cherry-picking between two publicly
64         visible branches (e.g. backporting a fix to a
65         maintenance branch for an older release from a
66         development branch), adding this information can be
67         useful.
69 -r::
70         It used to be that the command defaulted to do `-x`
71         described above, and `-r` was to disable it.  Now the
72         default is not to do `-x` so this option is a no-op.
74 -m parent-number::
75 --mainline parent-number::
76         Usually you cannot cherry-pick a merge because you do not know which
77         side of the merge should be considered the mainline.  This
78         option specifies the parent number (starting from 1) of
79         the mainline and allows cherry-pick to replay the change
80         relative to the specified parent.
82 -n::
83 --no-commit::
84         Usually the command automatically creates a sequence of commits.
85         This flag applies the changes necessary to cherry-pick
86         each named commit to your working tree and the index,
87         without making any commit.  In addition, when this
88         option is used, your index does not have to match the
89         HEAD commit.  The cherry-pick is done against the
90         beginning state of your index.
92 This is useful when cherry-picking more than one commits'
93 effect to your index in a row.
95 -s::
96 --signoff::
97         Add Signed-off-by line at the end of the commit message.
99 --ff::
100         If the current HEAD is the same as the parent of the
101         cherry-pick'ed commit, then a fast forward to this commit will
102         be performed.
104 --strategy=<strategy>::
105         Use the given merge strategy.  Should only be used once.
106         See the MERGE STRATEGIES section in linkgit:git-merge[1]
107         for details.
109 -X<option>::
110 --strategy-option=<option>::
111         Pass the merge strategy-specific option through to the
112         merge strategy.  See linkgit:git-merge[1] for details.
114 SEQUENCER SUBCOMMANDS
115 ---------------------
116 include::sequencer.txt[]
118 EXAMPLES
119 --------
120 git cherry-pick master::
122         Apply the change introduced by the commit at the tip of the
123         master branch and create a new commit with this change.
125 git cherry-pick ..master::
126 git cherry-pick ^HEAD master::
128         Apply the changes introduced by all commits that are ancestors
129         of master but not of HEAD to produce new commits.
131 git cherry-pick master{tilde}4 master{tilde}2::
133         Apply the changes introduced by the fifth and third last
134         commits pointed to by master and create 2 new commits with
135         these changes.
137 git cherry-pick -n master~1 next::
139         Apply to the working tree and the index the changes introduced
140         by the second last commit pointed to by master and by the last
141         commit pointed to by next, but do not create any commit with
142         these changes.
144 git cherry-pick --ff ..next::
146         If history is linear and HEAD is an ancestor of next, update
147         the working tree and advance the HEAD pointer to match next.
148         Otherwise, apply the changes introduced by those commits that
149         are in next but not HEAD to the current branch, creating a new
150         commit for each new change.
152 git rev-list --reverse master \-- README | git cherry-pick -n --stdin::
154         Apply the changes introduced by all commits on the master
155         branch that touched README to the working tree and index,
156         so the result can be inspected and made into a single new
157         commit if suitable.
159 The following sequence attempts to backport a patch, bails out because
160 the code the patch applies to has changed too much, and then tries
161 again, this time exercising more care about matching up context lines.
163 ------------
164 $ git cherry-pick topic^             <1>
165 $ git diff                           <2>
166 $ git reset --merge ORIG_HEAD        <3>
167 $ git cherry-pick -Xpatience topic^  <4>
168 ------------
169 <1> apply the change that would be shown by `git show topic^`.
170 In this example, the patch does not apply cleanly, so
171 information about the conflict is written to the index and
172 working tree and no new commit results.
173 <2> summarize changes to be reconciled
174 <3> cancel the cherry-pick.  In other words, return to the
175 pre-cherry-pick state, preserving any local modifications you had in
176 the working tree.
177 <4> try to apply the change introduced by `topic^` again,
178 spending extra time to avoid mistakes based on incorrectly matching
179 context lines.
181 SEE ALSO
182 --------
183 linkgit:git-revert[1]
187 Part of the linkgit:git[1] suite