test: remove httpd tests that ask for user
[git] / Documentation / git-cherry-pick.txt
1 git-cherry-pick(1)
2 ==================
3
4 NAME
5 ----
6 git-cherry-pick - Apply the changes introduced by some existing commits
7
8 SYNOPSIS
9 --------
10 [verse]
11 'git cherry-pick' [-q] [--edit] [-n] [-m parent-number] [-s] [-x] [--ff]
12                   [-S[<keyid>]] <commit>...
13 'git cherry-pick' --continue
14 'git cherry-pick' --skip
15 'git cherry-pick' --quit
16 'git cherry-pick' --abort
17
18 ALIAS
19 ~~~~~
20 'git pi'
21
22 DESCRIPTION
23 -----------
24
25 Given one or more existing commits, apply the change each one
26 introduces, recording a new commit for each.  This requires your
27 working tree to be clean (no modifications from the HEAD commit).
28
29 When it is not obvious how to apply a change, the following
30 happens:
31
32 1. The current branch and `HEAD` pointer stay at the last commit
33    successfully made.
34 2. The `CHERRY_PICK_HEAD` ref is set to point at the commit that
35    introduced the change that is difficult to apply.
36 3. Paths in which the change applied cleanly are updated both
37    in the index file and in your working tree.
38 4. For conflicting paths, the index file records up to three
39    versions, as described in the "TRUE MERGE" section of
40    linkgit:git-merge[1].  The working tree files will include
41    a description of the conflict bracketed by the usual
42    conflict markers `<<<<<<<` and `>>>>>>>`.
43 5. No other modifications are made.
44
45 See linkgit:git-merge[1] for some hints on resolving such
46 conflicts.
47
48 OPTIONS
49 -------
50 <commit>...::
51         Commits to cherry-pick.
52         For a more complete list of ways to spell commits, see
53         linkgit:gitrevisions[7].
54         Sets of commits can be passed but no traversal is done by
55         default, as if the '--no-walk' option was specified, see
56         linkgit:git-rev-list[1]. Note that specifying a range will
57         feed all <commit>... arguments to a single revision walk
58         (see a later example that uses 'maint master..next').
59
60 -q::
61 --quiet::
62         Quiet, suppress feedback messages.
63
64 -e::
65 --edit::
66         With this option, 'git cherry-pick' will let you edit the commit
67         message prior to committing.
68
69 -x::
70         When recording the commit, append a line that says
71         "(cherry picked from commit ...)" to the original commit
72         message in order to indicate which commit this change was
73         cherry-picked from.  This is done only for cherry
74         picks without conflicts.  Do not use this option if
75         you are cherry-picking from your private branch because
76         the information is useless to the recipient.  If on the
77         other hand you are cherry-picking between two publicly
78         visible branches (e.g. backporting a fix to a
79         maintenance branch for an older release from a
80         development branch), adding this information can be
81         useful.
82
83 -r::
84         It used to be that the command defaulted to do `-x`
85         described above, and `-r` was to disable it.  Now the
86         default is not to do `-x` so this option is a no-op.
87
88 -m parent-number::
89 --mainline parent-number::
90         Usually you cannot cherry-pick a merge because you do not know which
91         side of the merge should be considered the mainline.  This
92         option specifies the parent number (starting from 1) of
93         the mainline and allows cherry-pick to replay the change
94         relative to the specified parent.
95
96 -n::
97 --no-commit::
98         Usually the command automatically creates a sequence of commits.
99         This flag applies the changes necessary to cherry-pick
100         each named commit to your working tree and the index,
101         without making any commit.  In addition, when this
102         option is used, your index does not have to match the
103         HEAD commit.  The cherry-pick is done against the
104         beginning state of your index.
105 +
106 This is useful when cherry-picking more than one commits'
107 effect to your index in a row.
108
109 -s::
110 --signoff::
111         Add Signed-off-by line at the end of the commit message.
112         See the signoff option in linkgit:git-commit[1] for more information.
113
114 -S[<keyid>]::
115 --gpg-sign[=<keyid>]::
116         GPG-sign commits. The `keyid` argument is optional and
117         defaults to the committer identity; if specified, it must be
118         stuck to the option without a space.
119
120 --ff::
121         If the current HEAD is the same as the parent of the
122         cherry-pick'ed commit, then a fast forward to this commit will
123         be performed.
124
125 --allow-empty::
126         By default, cherry-picking an empty commit will fail,
127         indicating that an explicit invocation of `git commit
128         --allow-empty` is required. This option overrides that
129         behavior, allowing empty commits to be preserved automatically
130         in a cherry-pick. Note that when "--ff" is in effect, empty
131         commits that meet the "fast-forward" requirement will be kept
132         even without this option.  Note also, that use of this option only
133         keeps commits that were initially empty (i.e. the commit recorded the
134         same tree as its parent).  Commits which are made empty due to a
135         previous commit are dropped.  To force the inclusion of those commits
136         use `--keep-redundant-commits`.
137
138 --allow-empty-message::
139         By default, cherry-picking a commit with an empty message will fail.
140         This option overrides that behaviour, allowing commits with empty
141         messages to be cherry picked.
142
143 --keep-redundant-commits::
144         If a commit being cherry picked duplicates a commit already in the
145         current history, it will become empty.  By default these
146         redundant commits cause `cherry-pick` to stop so the user can
147         examine the commit. This option overrides that behavior and
148         creates an empty commit object.  Implies `--allow-empty`.
149
150 --skip-empty::
151         Instead of failing, skip commits that are or become empty.
152
153 --strategy=<strategy>::
154         Use the given merge strategy.  Should only be used once.
155         See the MERGE STRATEGIES section in linkgit:git-merge[1]
156         for details.
157
158 -X<option>::
159 --strategy-option=<option>::
160         Pass the merge strategy-specific option through to the
161         merge strategy.  See linkgit:git-merge[1] for details.
162
163 SEQUENCER SUBCOMMANDS
164 ---------------------
165 include::sequencer.txt[]
166
167 EXAMPLES
168 --------
169 `git cherry-pick master`::
170
171         Apply the change introduced by the commit at the tip of the
172         master branch and create a new commit with this change.
173
174 `git cherry-pick ..master`::
175 `git cherry-pick ^HEAD master`::
176
177         Apply the changes introduced by all commits that are ancestors
178         of master but not of HEAD to produce new commits.
179
180 `git cherry-pick maint next ^master`::
181 `git cherry-pick maint master..next`::
182
183         Apply the changes introduced by all commits that are
184         ancestors of maint or next, but not master or any of its
185         ancestors.  Note that the latter does not mean `maint` and
186         everything between `master` and `next`; specifically,
187         `maint` will not be used if it is included in `master`.
188
189 `git cherry-pick master~4 master~2`::
190
191         Apply the changes introduced by the fifth and third last
192         commits pointed to by master and create 2 new commits with
193         these changes.
194
195 `git cherry-pick -n master~1 next`::
196
197         Apply to the working tree and the index the changes introduced
198         by the second last commit pointed to by master and by the last
199         commit pointed to by next, but do not create any commit with
200         these changes.
201
202 `git cherry-pick --ff ..next`::
203
204         If history is linear and HEAD is an ancestor of next, update
205         the working tree and advance the HEAD pointer to match next.
206         Otherwise, apply the changes introduced by those commits that
207         are in next but not HEAD to the current branch, creating a new
208         commit for each new change.
209
210 `git rev-list --reverse master -- README | git cherry-pick -n --stdin`::
211
212         Apply the changes introduced by all commits on the master
213         branch that touched README to the working tree and index,
214         so the result can be inspected and made into a single new
215         commit if suitable.
216
217 The following sequence attempts to backport a patch, bails out because
218 the code the patch applies to has changed too much, and then tries
219 again, this time exercising more care about matching up context lines.
220
221 ------------
222 $ git cherry-pick topic^             <1>
223 $ git diff                           <2>
224 $ git reset --merge ORIG_HEAD        <3>
225 $ git cherry-pick -Xpatience topic^  <4>
226 ------------
227 <1> apply the change that would be shown by `git show topic^`.
228 In this example, the patch does not apply cleanly, so
229 information about the conflict is written to the index and
230 working tree and no new commit results.
231 <2> summarize changes to be reconciled
232 <3> cancel the cherry-pick.  In other words, return to the
233 pre-cherry-pick state, preserving any local modifications you had in
234 the working tree.
235 <4> try to apply the change introduced by `topic^` again,
236 spending extra time to avoid mistakes based on incorrectly matching
237 context lines.
238
239 SEE ALSO
240 --------
241 linkgit:git-revert[1]
242
243 GIT
244 ---
245 Part of the linkgit:git[1] suite