less than 1 minute read

Cherry picking a range of commits is not too difficult, but it does come with a strange syntax that I often forget. The basic form of cherry picking a range of commits is:

git cherry-pick ebe6942..905e279

The first hash in the range is the oldest commit and the last hash in the range is the newest commit. The confusion with this form of the cherry pick merge is that the first hash listed in the range is not included in the commit. The last hash is included. I find it difficult to keep track of which hash is included and which is not.

As a result, my preferred syntax for including a range of commits in a cherry pick that is inclusive of both range endpoints is:

git cherry-pick ebe6942^..905e279

This syntax will include the first commit object. This inclusion is what I assume the range commit will do by default and I often get tripped up and confused by it.

Via tollmanz.com.

Thanks to Russ Gunther for the tip!

Tags: , ,

Categories:

Updated:

Leave a comment