git cherry is a useful part of the git suite that allows you to find commits that have yet to be applied to an upstream branch. Let’s say you have an upstream branch origin/my-cool-feature.

To see how your HEAD compares with the upstream branch, you can run git cherry origin/my-cool-feature. You will then see a list of commits yet to be applied to origin/my-cool-feature:

- abcdefg123456...
+ jiw8134dadzfw...
+ zyxwvut123987...

Those commits marked with a - can be dropped from HEAD when rebased on top of origin/my-cool-feature. The commits with a + will need to be kept so that they can be applied to the upstream branch.

I found git cherry to be useful today when I wanted to compare a local branch to a branch we were testing for an upcoming release. I wanted to see whether some commits in master had been cherry-picked into our release, and git cherry -v our-release-candidate provided a nice list of the differences between the two branches (the useful -v flag outputs the commit subjects next to the SHA1s).