Let's assume you have this:
A B C F G -------o---o---o-----o----o devel / \ o------------------o----o---o master D E H
The last release was at commit D, which was a --no-ff merge from devel, and it included the commits (A, B, C). Another developer continued developing new features on devel, producing (F, G), and we noticed that we unfortunately deployed two bugs to production, so we had to quickly fix that, which produced commits (E, H). Now, we want a command, that will tell us what commits are missing from devel, but are present in master (did the hotfixes get merged into devel?), so it should output (E, H):
git cherry -v devel master + b4920f0d6e4bdd9be1ebd87a1fe0bb8b9c706c0b E + 1ae5c901e8cbd9819db6d6543cfcea4346971cf0 H
The command works regardless of where your current HEAD is. We can obviously switch the parameters, to get a list of what is missing from master, but present on devel (what new features were developed, that are not yet deployed?):
git cherry -v master devel + 9b093e3473e964fe0508b6a82e3b3c513e6e4dba F + c1806374bd3c75bd7f7f5e0919c477874e30eb0d G
Cherry-picking the chaos
What do the + signs mean? A + means that the commit is missing from branch A, but present in branch B. A - sign means that the commit is present in both, but with a different commit-id. You see, git is clever enough to identify a commit as a copy of another commit, even if they have different commit ids, because it looks at the diff of the commit, to determine if they match or not. For example, let's cherry-pick hotfix H into devel:
A B C F G H -------o---o---o-----o----o----o devel / \ o------------------o----o---o master D E H git cherry -v devel master + b4920f0d6e4bdd9be1ebd87a1fe0bb8b9c706c0b E - 1ae5c901e8cbd9819db6d6543cfcea4346971cf0 H git cherry -v master devel + 9b093e3473e964fe0508b6a82e3b3c513e6e4dba F + c1806374bd3c75bd7f7f5e0919c477874e30eb0d G - 3b9baacf35a01b6e65005aa1d96017ce6a5990ee H
The two H commits have separate SHA1 ids, but instead of listing it as missing, git is clever enough to tell us that H is already present, but with a different commit id, so we don't have to worry about it.