3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
7 .\" Source: Git 2.46.0.rc0.75.g04f5a52757
10 .TH "GIT\-CHERRY" "1" "2024\-07\-16" "Git 2\&.46\&.0\&.rc0\&.75\&.g0" "Git Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 git-cherry \- Find commits yet to be applied to upstream
35 \fIgit cherry\fR [\-v] [<upstream> [<head> [<limit>]]]
40 Determine whether there are commits in \fB<head>\&.\&.<upstream>\fR that are equivalent to those in the range \fB<limit>\&.\&.<head>\fR\&.
42 The equivalence test is based on the diff, after removing whitespace and line numbers\&. git\-cherry therefore detects when commits have been "copied" by means of \fBgit-cherry-pick\fR(1), \fBgit-am\fR(1) or \fBgit-rebase\fR(1)\&.
44 Outputs the SHA1 of every commit in \fB<limit>\&.\&.<head>\fR, prefixed with \fB\-\fR for commits that have an equivalent in <upstream>, and \fB+\fR for commits that do not\&.
49 Show the commit subjects next to the SHA1s\&.
54 Upstream branch to search for equivalent commits\&. Defaults to the upstream branch of HEAD\&.
59 Working branch; defaults to HEAD\&.
64 Do not report commits up to (and including) limit\&.
69 git\-cherry is frequently used in patch\-based workflows (see \fBgitworkflows\fR(7)) to determine if a series of patches has been applied by the upstream maintainer\&. In such a workflow you might create and send a topic branch like this:
75 $ git checkout \-b topic origin/master
76 # work and create some commits
77 $ git format\-patch origin/master
78 $ git send\-email \&.\&.\&. 00*
85 Later, you can see whether your changes have been applied by saying (still on \fBtopic\fR):
91 $ git fetch # update your notion of origin/master
98 .SS "Concrete example"
100 In a situation where topic consisted of three commits, and the maintainer applied two of them, the situation might look like:
106 $ git log \-\-graph \-\-oneline \-\-decorate \-\-boundary origin/master\&.\&.\&.topic
107 * 7654321 (origin/master) upstream tip commit
108 [\&.\&.\&. snip some other commits \&.\&.\&.]
109 * cccc111 cherry\-pick of C
110 * aaaa111 cherry\-pick of A
111 [\&.\&.\&. snip a lot more that has happened \&.\&.\&.]
112 | * cccc000 (topic) commit C
116 o 1234567 branch point
123 In such cases, git\-cherry shows a concise summary of what has yet to be applied:
129 $ git cherry origin/master topic
130 \- cccc000\&.\&.\&. commit C
131 + bbbb000\&.\&.\&. commit B
132 \- aaaa000\&.\&.\&. commit A
139 Here, we see that the commits A and C (marked with \fB\-\fR) can be dropped from your \fBtopic\fR branch when you rebase it on top of \fBorigin/master\fR, while the commit B (marked with \fB+\fR) still needs to be kept so that it will be sent to be applied to \fBorigin/master\fR\&.
142 The optional <limit> is useful in cases where your topic is based on other work that is not in upstream\&. Expanding on the previous example, this might look like:
148 $ git log \-\-graph \-\-oneline \-\-decorate \-\-boundary origin/master\&.\&.\&.topic
149 * 7654321 (origin/master) upstream tip commit
150 [\&.\&.\&. snip some other commits \&.\&.\&.]
151 * cccc111 cherry\-pick of C
152 * aaaa111 cherry\-pick of A
153 [\&.\&.\&. snip a lot more that has happened \&.\&.\&.]
154 | * cccc000 (topic) commit C
157 | * 0000fff (base) unpublished stuff F
158 [\&.\&.\&. snip \&.\&.\&.]
159 | * 0000aaa unpublished stuff A
161 o 1234567 merge\-base between upstream and topic
168 By specifying \fBbase\fR as the limit, you can avoid listing commits between \fBbase\fR and \fBtopic\fR:
174 $ git cherry origin/master topic base
175 \- cccc000\&.\&.\&. commit C
176 + bbbb000\&.\&.\&. commit B
177 \- aaaa000\&.\&.\&. commit A
185 \fBgit-patch-id\fR(1)
188 Part of the \fBgit\fR(1) suite