MSVC: require pton and ntop emulation
[git/dscho.git] / Documentation / git-cherry-pick.txt
blob9f3dae631e5437662e9fb3583b24f414c93bb140
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 [verse]
11 'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] [--ff] <commit>...
12 'git cherry-pick' --continue
13 'git cherry-pick' --quit
14 'git cherry-pick' --abort
16 DESCRIPTION
17 -----------
19 Given one or more existing commits, apply the change each one
20 introduces, recording a new commit for each.  This requires your
21 working tree to be clean (no modifications from the HEAD commit).
23 When it is not obvious how to apply a change, the following
24 happens:
26 1. The current branch and `HEAD` pointer stay at the last commit
27    successfully made.
28 2. The `CHERRY_PICK_HEAD` ref is set to point at the commit that
29    introduced the change that is difficult to apply.
30 3. Paths in which the change applied cleanly are updated both
31    in the index file and in your working tree.
32 4. For conflicting paths, the index file records up to three
33    versions, as described in the "TRUE MERGE" section of
34    linkgit:git-merge[1].  The working tree files will include
35    a description of the conflict bracketed by the usual
36    conflict markers `<<<<<<<` and `>>>>>>>`.
37 5. No other modifications are made.
39 See linkgit:git-merge[1] for some hints on resolving such
40 conflicts.
42 OPTIONS
43 -------
44 <commit>...::
45         Commits to cherry-pick.
46         For a more complete list of ways to spell commits, see
47         linkgit:gitrevisions[7].
48         Sets of commits can be passed but no traversal is done by
49         default, as if the '--no-walk' option was specified, see
50         linkgit:git-rev-list[1].
52 -e::
53 --edit::
54         With this option, 'git cherry-pick' will let you edit the commit
55         message prior to committing.
57 -x::
58         When recording the commit, append a line that says
59         "(cherry picked from commit ...)" to the original commit
60         message in order to indicate which commit this change was
61         cherry-picked from.  This is done only for cherry
62         picks without conflicts.  Do not use this option if
63         you are cherry-picking from your private branch because
64         the information is useless to the recipient.  If on the
65         other hand you are cherry-picking between two publicly
66         visible branches (e.g. backporting a fix to a
67         maintenance branch for an older release from a
68         development branch), adding this information can be
69         useful.
71 -r::
72         It used to be that the command defaulted to do `-x`
73         described above, and `-r` was to disable it.  Now the
74         default is not to do `-x` so this option is a no-op.
76 -m parent-number::
77 --mainline parent-number::
78         Usually you cannot cherry-pick a merge because you do not know which
79         side of the merge should be considered the mainline.  This
80         option specifies the parent number (starting from 1) of
81         the mainline and allows cherry-pick to replay the change
82         relative to the specified parent.
84 -n::
85 --no-commit::
86         Usually the command automatically creates a sequence of commits.
87         This flag applies the changes necessary to cherry-pick
88         each named commit to your working tree and the index,
89         without making any commit.  In addition, when this
90         option is used, your index does not have to match the
91         HEAD commit.  The cherry-pick is done against the
92         beginning state of your index.
94 This is useful when cherry-picking more than one commits'
95 effect to your index in a row.
97 -s::
98 --signoff::
99         Add Signed-off-by line at the end of the commit message.
101 --ff::
102         If the current HEAD is the same as the parent of the
103         cherry-pick'ed commit, then a fast forward to this commit will
104         be performed.
106 --allow-empty::
107         By default, cherry-picking an empty commit will fail,
108         indicating that an explicit invocation of `git commit
109         --allow-empty` is required. This option overrides that
110         behavior, allowing empty commits to be preserved automatically
111         in a cherry-pick. Note that when "--ff" is in effect, empty
112         commits that meet the "fast-forward" requirement will be kept
113         even without this option.  Note also, that use of this option only
114         keeps commits that were initially empty (i.e. the commit recorded the
115         same tree as its parent).  Commits which are made empty due to a
116         previous commit are dropped.  To force the inclusion of those commits
117         use `--keep-redundant-commits`.
119 --keep-redundant-commits::
120         If a commit being cherry picked duplicates a commit already in the
121         current history, it will become empty.  By default these
122         redundant commits are ignored.  This option overrides that behavior and
123         creates an empty commit object.  Implies `--allow-empty`.
125 --strategy=<strategy>::
126         Use the given merge strategy.  Should only be used once.
127         See the MERGE STRATEGIES section in linkgit:git-merge[1]
128         for details.
130 -X<option>::
131 --strategy-option=<option>::
132         Pass the merge strategy-specific option through to the
133         merge strategy.  See linkgit:git-merge[1] for details.
135 SEQUENCER SUBCOMMANDS
136 ---------------------
137 include::sequencer.txt[]
139 EXAMPLES
140 --------
141 `git cherry-pick master`::
143         Apply the change introduced by the commit at the tip of the
144         master branch and create a new commit with this change.
146 `git cherry-pick ..master`::
147 `git cherry-pick ^HEAD master`::
149         Apply the changes introduced by all commits that are ancestors
150         of master but not of HEAD to produce new commits.
152 `git cherry-pick master~4 master~2`::
154         Apply the changes introduced by the fifth and third last
155         commits pointed to by master and create 2 new commits with
156         these changes.
158 `git cherry-pick -n master~1 next`::
160         Apply to the working tree and the index the changes introduced
161         by the second last commit pointed to by master and by the last
162         commit pointed to by next, but do not create any commit with
163         these changes.
165 `git cherry-pick --ff ..next`::
167         If history is linear and HEAD is an ancestor of next, update
168         the working tree and advance the HEAD pointer to match next.
169         Otherwise, apply the changes introduced by those commits that
170         are in next but not HEAD to the current branch, creating a new
171         commit for each new change.
173 `git rev-list --reverse master -- README | git cherry-pick -n --stdin`::
175         Apply the changes introduced by all commits on the master
176         branch that touched README to the working tree and index,
177         so the result can be inspected and made into a single new
178         commit if suitable.
180 The following sequence attempts to backport a patch, bails out because
181 the code the patch applies to has changed too much, and then tries
182 again, this time exercising more care about matching up context lines.
184 ------------
185 $ git cherry-pick topic^             <1>
186 $ git diff                           <2>
187 $ git reset --merge ORIG_HEAD        <3>
188 $ git cherry-pick -Xpatience topic^  <4>
189 ------------
190 <1> apply the change that would be shown by `git show topic^`.
191 In this example, the patch does not apply cleanly, so
192 information about the conflict is written to the index and
193 working tree and no new commit results.
194 <2> summarize changes to be reconciled
195 <3> cancel the cherry-pick.  In other words, return to the
196 pre-cherry-pick state, preserving any local modifications you had in
197 the working tree.
198 <4> try to apply the change introduced by `topic^` again,
199 spending extra time to avoid mistakes based on incorrectly matching
200 context lines.
202 SEE ALSO
203 --------
204 linkgit:git-revert[1]
208 Part of the linkgit:git[1] suite