Git Tips: Cherry Picking Logs

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.

--

--

--

I turn beer into software. Be good humans.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Drew Stokes

Drew Stokes

I turn beer into software. Be good humans.

More from Medium

Refactoring

A Simple Programmatic Approach to create a modal popup using pure Javascript, without using…

Simple array sum HackerRank

Terrain Rendering via Perlin Noise and OpenGL Geometry Shaders