3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets v1.79.2 <http://docbook.sf.net/>
7 .\" Source: Git 2.47.0.rc0.18.ge9356ba3ea
10 .TH "GIT\-CHERRY" "1" "2024-09-30" "Git 2\&.47\&.0\&.rc0\&.18\&.ge" "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>]]]
39 Determine whether there are commits in \fB<head>\&.\&.<upstream>\fR that are equivalent to those in the range \fB<limit>\&.\&.<head>\fR\&.
41 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)\&.
43 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\&.
48 Show the commit subjects next to the SHA1s\&.
53 Upstream branch to search for equivalent commits\&. Defaults to the upstream branch of HEAD\&.
58 Working branch; defaults to HEAD\&.
63 Do not report commits up to (and including) limit\&.
68 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:
74 $ git checkout \-b topic origin/master
75 # work and create some commits
76 $ git format\-patch origin/master
77 $ git send\-email \&.\&.\&. 00*
83 Later, you can see whether your changes have been applied by saying (still on \fBtopic\fR):
89 $ git fetch # update your notion of origin/master
95 .SS "Concrete example"
97 In a situation where topic consisted of three commits, and the maintainer applied two of them, the situation might look like:
103 $ git log \-\-graph \-\-oneline \-\-decorate \-\-boundary origin/master\&.\&.\&.topic
104 * 7654321 (origin/master) upstream tip commit
105 [\&.\&.\&. snip some other commits \&.\&.\&.]
106 * cccc111 cherry\-pick of C
107 * aaaa111 cherry\-pick of A
108 [\&.\&.\&. snip a lot more that has happened \&.\&.\&.]
109 | * cccc000 (topic) commit C
113 o 1234567 branch point
119 In such cases, git\-cherry shows a concise summary of what has yet to be applied:
125 $ git cherry origin/master topic
126 \- cccc000\&.\&.\&. commit C
127 + bbbb000\&.\&.\&. commit B
128 \- aaaa000\&.\&.\&. commit A
134 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\&.
137 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:
143 $ git log \-\-graph \-\-oneline \-\-decorate \-\-boundary origin/master\&.\&.\&.topic
144 * 7654321 (origin/master) upstream tip commit
145 [\&.\&.\&. snip some other commits \&.\&.\&.]
146 * cccc111 cherry\-pick of C
147 * aaaa111 cherry\-pick of A
148 [\&.\&.\&. snip a lot more that has happened \&.\&.\&.]
149 | * cccc000 (topic) commit C
152 | * 0000fff (base) unpublished stuff F
153 [\&.\&.\&. snip \&.\&.\&.]
154 | * 0000aaa unpublished stuff A
156 o 1234567 merge\-base between upstream and topic
162 By specifying \fBbase\fR as the limit, you can avoid listing commits between \fBbase\fR and \fBtopic\fR:
168 $ git cherry origin/master topic base
169 \- cccc000\&.\&.\&. commit C
170 + bbbb000\&.\&.\&. commit B
171 \- aaaa000\&.\&.\&. commit A
178 \fBgit-patch-id\fR(1)
181 Part of the \fBgit\fR(1) suite