1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE sect2 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
\r
4 <sect2 lang="en" id="git-cherry(1)">
\r
5 <title>git-cherry(1)</title>
\r
7 <primary>git-cherry(1)</primary>
\r
9 <simplesect id="git-cherry(1)__name">
\r
11 <simpara>git-cherry - Find commits yet to be applied to upstream</simpara>
\r
13 <simplesect id="git-cherry(1)__synopsis">
\r
14 <title>SYNOPSIS</title>
\r
16 <literallayout><emphasis>git cherry</emphasis> [-v] [<upstream> [<head> [<limit>]]]</literallayout>
\r
19 <simplesect id="git-cherry(1)__description">
\r
20 <title>DESCRIPTION</title>
\r
21 <simpara>Determine whether there are commits in <emphasis><head>..<upstream></emphasis> that are
\r
22 equivalent to those in the range <emphasis><limit>..<head></emphasis>.</simpara>
\r
23 <simpara>The equivalence test is based on the diff, after removing whitespace
\r
24 and line numbers. git-cherry therefore detects when commits have been
\r
25 "copied" by means of <xref linkend="git-cherry-pick(1)" />, <xref linkend="git-am(1)" /> or
\r
26 <xref linkend="git-rebase(1)" />.</simpara>
\r
27 <simpara>Outputs the SHA1 of every commit in <emphasis><limit>..<head></emphasis>, prefixed with
\r
28 <emphasis>-</emphasis> for commits that have an equivalent in <upstream>, and <emphasis>+</emphasis> for
\r
29 commits that do not.</simpara>
\r
31 <simplesect id="git-cherry(1)__options">
\r
32 <title>OPTIONS</title>
\r
40 Show the commit subjects next to the SHA1s.
\r
50 Upstream branch to search for equivalent commits.
\r
51 Defaults to the upstream branch of HEAD.
\r
61 Working branch; defaults to HEAD.
\r
71 Do not report commits up to (and including) limit.
\r
77 <simplesect id="git-cherry(1)__examples">
\r
78 <title>EXAMPLES</title>
\r
79 <section id="git-cherry(1)__patch_workflows">
\r
80 <title>Patch workflows</title>
\r
81 <simpara>git-cherry is frequently used in patch-based workflows (see
\r
82 <xref linkend="gitworkflows(7)" />) to determine if a series of patches has been
\r
83 applied by the upstream maintainer. In such a workflow you might
\r
84 create and send a topic branch like this:</simpara>
\r
85 <screen>$ git checkout -b topic origin/master
\r
86 # work and create some commits
\r
87 $ git format-patch origin/master
\r
88 $ git send-email ... 00*</screen>
\r
89 <simpara>Later, you can see whether your changes have been applied by saying
\r
90 (still on <emphasis>topic</emphasis>):</simpara>
\r
91 <screen>$ git fetch # update your notion of origin/master
\r
92 $ git cherry -v</screen>
\r
94 <section id="git-cherry(1)__concrete_example">
\r
95 <title>Concrete example</title>
\r
96 <simpara>In a situation where topic consisted of three commits, and the
\r
97 maintainer applied two of them, the situation might look like:</simpara>
\r
98 <screen>$ git log --graph --oneline --decorate --boundary origin/master...topic
\r
99 * 7654321 (origin/master) upstream tip commit
\r
100 [... snip some other commits ...]
\r
101 * cccc111 cherry-pick of C
\r
102 * aaaa111 cherry-pick of A
\r
103 [... snip a lot more that has happened ...]
\r
104 | * cccc000 (topic) commit C
\r
105 | * bbbb000 commit B
\r
106 | * aaaa000 commit A
\r
108 o 1234567 branch point</screen>
\r
109 <simpara>In such cases, git-cherry shows a concise summary of what has yet to
\r
110 be applied:</simpara>
\r
111 <screen>$ git cherry origin/master topic
\r
112 - cccc000... commit C
\r
113 + bbbb000... commit B
\r
114 - aaaa000... commit A</screen>
\r
115 <simpara>Here, we see that the commits A and C (marked with <emphasis>-</emphasis>) can be
\r
116 dropped from your <emphasis>topic</emphasis> branch when you rebase it on top of
\r
117 <emphasis>origin/master</emphasis>, while the commit B (marked with <emphasis>+</emphasis>) still needs to
\r
118 be kept so that it will be sent to be applied to <emphasis>origin/master</emphasis>.</simpara>
\r
120 <section id="git-cherry(1)__using_a_limit">
\r
121 <title>Using a limit</title>
\r
122 <simpara>The optional <limit> is useful in cases where your topic is based on
\r
123 other work that is not in upstream. Expanding on the previous
\r
124 example, this might look like:</simpara>
\r
125 <screen>$ git log --graph --oneline --decorate --boundary origin/master...topic
\r
126 * 7654321 (origin/master) upstream tip commit
\r
127 [... snip some other commits ...]
\r
128 * cccc111 cherry-pick of C
\r
129 * aaaa111 cherry-pick of A
\r
130 [... snip a lot more that has happened ...]
\r
131 | * cccc000 (topic) commit C
\r
132 | * bbbb000 commit B
\r
133 | * aaaa000 commit A
\r
134 | * 0000fff (base) unpublished stuff F
\r
136 | * 0000aaa unpublished stuff A
\r
138 o 1234567 merge-base between upstream and topic</screen>
\r
139 <simpara>By specifying <emphasis>base</emphasis> as the limit, you can avoid listing commits
\r
140 between <emphasis>base</emphasis> and <emphasis>topic</emphasis>:</simpara>
\r
141 <screen>$ git cherry origin/master topic base
\r
142 - cccc000... commit C
\r
143 + bbbb000... commit B
\r
144 - aaaa000... commit A</screen>
\r
147 <simplesect id="git-cherry(1)__see_also">
\r
148 <title>SEE ALSO</title>
\r
149 <simpara><xref linkend="git-patch-id(1)" /></simpara>
\r
151 <simplesect id="git-cherry(1)__git">
\r
153 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
\r