Cherry picking commits with GIT

I have a project in which I’m maintaining both a beta and a release branch. Bugfixes need to be applied to both branches, except in cases where the bug has already been fixed in the release branch, in which case it would only need to be addressed in the beta branch.

Yesterday I ran into a case where I wanted to just merge a single commit from “beta” to “release” in order to apply a fix from “beta” directly to “release.”

It Kind of blew my mind how easy this was…

Mind Blown!


1. Find the commit you want to take from the source branch beta. In this case its hash was af19aadbcfa61d2d2816307044318d637d35cee5.

git log

2. Switch to the branch where you want to apply the commit.

git checkout release

3. Apply the commit from dev as a new commit of equivalent changes to the beta branch.

git cherry-pick af19aadbcfa61d2d2816307044318d637d35cee5

4. Resolve any merge conflicts(this may happen automatically if no conflicts)

git mergetool

5. Commit (this may happen automatically, I forget)

git commit

6. Push your changes to your GIT remote.

git push

Commit in beta [insert image a]

Commit in release [insert image b]

Charts and explanation stuffs

You can also string these together to apply more than one commit at a time, but that’s content for another post.

In addition to not imploding our universe into a parallel one with talking sheep, this just worked as expected. Slightly shocking…

Happy GITing.

Leave a Reply