Skip to content
Latchkey

git cherry: Usage, Options & Common CI Errors

git cherry tells you which of your commits are already upstream and which are not.

Before backporting or re-pushing, cherry distinguishes commits whose change is already present upstream (by patch id) from those still missing - handy for release and backport gates.

What it does

git cherry compares a branch against an upstream and marks each commit with - if an equivalent change already exists upstream (matched by patch id) or + if it does not.

Common usage

Terminal
git cherry -v main feature
git cherry main                 # upstream=main, head=current
git cherry -v upstream/main HEAD
# count unmerged commits:
git cherry main feature | grep -c '^+'

Options

FlagWhat it does
-vShow commit subjects alongside markers
<upstream>Branch to compare against
<head>Branch to examine (default: HEAD)
<limit>Restrict to commits after this point

Common errors in CI

cherry matches by patch id, so a commit that was rebased or slightly modified still shows + even though it is logically present - do not treat + as "definitely missing". A shallow clone can also skew results because the upstream history needed for patch-id matching is incomplete.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →