1

I have dev and main branches. Some commits go to the dev branch and then some of the dev branch commits go into the main branch. Which means, there are several commits in dev branch which are not submitted/cherry-picked in main branch at any given time.

I wonder if there is a way to log all dev commits which are new or which are not cherry-picked into main.

I tried with,

$git log main..dev
$git log dev..main

but they don't serve my purpose.

Sazzad Hissain Khan
  • 29,428
  • 20
  • 134
  • 192

1 Answers1

2

You can rebase in your local clone of the repo your dev branch on top of main: any commit already cherry-picked would not be replayed on top of main.

Or, simpler:

git cherry -v main dev

This would show all of the commits which are contained within dev, but not in main.
See "Git log to get commits only for a specific branch".

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • I was preparing a list with --pretty option while logging, but cherry has no such option. :( is there any workaround. Thanks for your help. – Sazzad Hissain Khan Aug 10 '17 at 05:32
  • 2
    @SazzadHissainKhan you can pipe the result of the `git cherry` command to a `git log -1`, in order to display each commit found as you want. – VonC Aug 10 '17 at 06:12
  • Thanks a lot @VonC – Sazzad Hissain Khan Aug 10 '17 at 08:32
  • I see `git log` does not read from stdin (https://stackoverflow.com/a/37325995/1084174) . I am unable to pipe into `git log`. Even using `xargs` it does not work. `git cherry main dev | grep ^- | tr -d "-" | xargs git log -1` it always shows last single commit. How can I solve it? – Sazzad Hissain Khan Aug 11 '17 at 07:00
  • @SazzadHissainKhan Can you redirect the ouput of `git cherry` to a file? And then https://stackoverflow.com/a/12521546/6309 (replacing `git cherry` by `git log`) – VonC Aug 11 '17 at 07:03
  • I can but that would be complicated for my developers. I was searching for a better workaround as an PI member. Any idea except creating files as it would be frequent. – Sazzad Hissain Khan Aug 11 '17 at 07:10
  • 1
    @SazzadHissainKhan I understand. Yet, that can be scripted, and deployed as a command for the developers to use. – VonC Aug 11 '17 at 07:11