Git cherry-pick

cherry-pick is a useful Git command, especially if you are working in an Agile team.

We used it for the first time today on our project.

Team member A lets call him “James” made a feature and put it onto master.

Team member B lets call him “Jordan” later refactered some code from “James”‘s feature.  Later that day, James also wanted to refactor that code, but “Jordan” had not finished his story and so “James” had to wait until Jordan had finished before starting his refactor otherwise face horrible conflicts.

Instead of waiting, “Jordan” created a commit for the refactor, push it in his feature branch to remote.  James pulled down the commit, cherry-picked it from “Jordan”‘s feature branch and continued on with his own refactoring.

Another great example of Git being more than just version control.

Posted on May 14, 2010 at 1:15 pm by Jordan Carter · Permalink
In: Ruby on Rails · Tagged with: 

3 Responses

  1. Written by justpointingout
    on August 19, 2010 at 3:42 am
    Permalink

    Perhaps you should provide examples of the actual use, rather than the scenario on its own

  2. Written by Jordan Carter
    on August 22, 2010 at 2:24 pm
    Permalink

    Yes, in hindsight that wouldn’t make a lot of sense to somebody. I will try update with an example. Sorry!

  3. Written by Keith Bowes
    on October 1, 2011 at 2:12 pm
    Permalink

    In other words, it’s a command to get around the limitations of a distributed version-control system (instead of committing each change you make, you keep all the changes in a local repository until you’re finished and then have to cherry-pick some changes you want to publish; robbing Peter to pay Paul).

Leave a Reply