6

Is there some way, maybe using git log, that I can see if any of my commits in "develop" have not been cherry-picked to "otherbranch" yet?

For example I make 6 commits to develop, and cherry-pick 5 of them to otherbranch. What git log command could I execute to output the 1 commit I missed?

(All our commits are pushed through Gerrit, so any Gerrit based solutions would help too.)

Chicowitz
  • 5,759
  • 5
  • 32
  • 38

2 Answers2

7
git log --cherry otherbranch...develop

should do it.

Log options --cherry-mark, --left-only, --right-only, --cherry and --cherry-pick that show various selections of similar or dissimilar commits on a ... (two-branch aka "symmetric difference") log. Also, --left-right shows for each commit whether its changes appear only on the left branch, right branch, or both.

jthill
  • 55,082
  • 5
  • 77
  • 137
  • Cherry-pick makes a new commit that applies the same changes. You're seeing the original commit and the cherry-picked commit. – jthill Feb 18 '17 at 20:32
  • So If I make 6 commits to develop, and cherry-pick 5 of those commits to otherbranch, I'd expect there to be a git log command that outputs the 1 commit. What would that be? – Chicowitz Feb 18 '17 at 20:41
  • `git log --right-only otherbranch...develop`, I think. Try `git help log`. – jthill Feb 18 '17 at 20:55
  • 1
    Besides `--cherry` (which is a synonym for `--right-only --cherry-mark --no-merges` you can use `--right-only --cherry-pick --no-merges`. The difference is that `--cherry-mark` *marks* the commits (as equivalent or not), while `--cherry-pick` *skips* the equivalent commits. The `git cherry` command is like similar, although I prefer the direct symmetric difference for instruction purposes: `git cherry` is what you use *after* you know all the above. :-) – torek Feb 18 '17 at 23:11
-1

Since some commits from develop branch cherry-pick to otherbranch, the commit id will be different. If you use git log --cherry otherbranch..develop, you will see all the commits which exist in develop branch (including the commits cherry-pich to otherbranch).

If your commit comments are unique, you can search the commits cherry-pick to otherbranch by

git log develop..otherbranch --grep=comment1 --grep=comment2 --grep=comment3 --grep=comment4 --grep=comment5 --grep=comment6 --oneline

So the commits which are not cherry-pick to otherbranch is opposite.

Marina Liu
  • 36,876
  • 5
  • 61
  • 74