Git Tips: Cherry Picking Logs
Show commit diffs between branches
The git commit log is one of the best tools for understanding the history and direction of a project. I’ve found there are a ton of situations where the log can make complex interactions with a repo a breeze.
Sometimes a branch you want to update can fall too far behind it’s base branch and a merge could introduce potentially unwanted commits. To find the difference in commits between two branches, use the —cherry-pick option:
git log --left-right --graph --cherry-pick --oneline master...production
< f472340 unshared commit in master branch
> 284f4b9 unshared commit in production branch
The —cherry-pick extracts commits that exist in one branch but not the other, while —left-right indicates which side the commit belongs to.
This gives you a commit summary of the changes that would be introduced by a merge hopefully saving you from having to trudge through line changes in a diff.