Search code examples
gitgit-log

Ignore git log cross-branch duplicates


If I perform git log -g, for instance, the results will include many commits containing the same content (for example, commits with the same diff but cherry picked to different branches). How can I have git log only show one of those commits and ignore others with duplicate diff content?


Solution

  • I think you need the --cherry-pick option. In my test:

     git log -g --format="%h %s %b"
     3301841 improve readme (cherry picked from commit ...)
     731e382 test
     613e970 improve readme
    

    With --cherry-pick, I only get the 3301841.

    --cherry-pick Omit any commit that introduces the same change as another commit on the “other side” when the set of commits are limited with symmetric difference.