Tuesday, April 26, 2016

Cherry Pick! What an amazing command


Introduction

Well, I've used cherry pick several times. It is a very useful tool that you will use it a lot when you understand how it works. 

Basically speaking, you will need it when you have 2 different branches that some people are developing concurrently and you want some of the changes to be implemented in both. Some might say that, we will copy the code. Well, then you will have merge errors, and if you are the one who is responsible for merges you will know that how painful it is when you want to understand which side to choose and how to merge, specially when it is not your code.

Using cherry pick, you are actually taking some code from a branch and applying it to yours, but at the same time, you are telling to your source control that you are applying one of its changes to your branch, so when you are going to merge 2 branches together, it will understand that you've already applied the change on your branch.

When you realize that you love it!

OK, I have 2 separate branches now and I want one of them to have all of the changes in the other branch, but I have some changes that I don't want to merge for 1 day or 2. Well, I it was the time that I realize how much I love this command. It is very fast and easy to use, specially with source tree. :)


Steps On Source-Tree
It can be done with these steps:

1- Select your branch (the one that you want to apply the change) as your current branch

2- On log/history window, there is a drop-down on top left, select "All Branches" instead of "Current Branch" so you can see all changes in all branches.

3- Select changes that you want using ctrl+left-click or Shift-left-click. then right click on selection and choose cherry-pick! 


Congratulations, you have done your first cherry pick! :) very easy! Right?! 

No comments:

Post a Comment