Thursday, July 10, 2014

Cherry-pick

Today I've learned about wonderful Git utility, which allows you to save a lot of time. The happy is "cherry-pick".

Let's imagine: you develop in any branch. And, you do some commits. After, you understand that something was wrong may be, and you want to test changes from an one commit separately, in a new branch or, may be, in your branch for core development. In other words, you want to get some changes without others. Well, reverting, may be, is not a good idea here, cause you can wish changes not from last commit. Cherry-pick will help you.
What is you need to do:

  1. See your commit history by git log, find one which is needed. It is more simple with GUI-interface, but git show <commit #> is enough also.
  2. When ID of your commit is founded, create a new branch for further work.
  3. Checkout to a new branch.
  4. Then, type a command git cherry-pick <commit #>, where # - ID of desired commit. If you don't want that a new branch commit at once, use -n parameter.
  5. You can get some conflicts at merging, so, be attentive.

No comments:

Post a Comment