Git merge, resolve conflict & Cherrypick

For git merge you always have to checkout to the branch in which merge changes needs to appear.

For example ABC branch needs to be merged into master then you need to checkout into master branch and then run the below command

git merge branch_name

After merge if there are any conflicts then we need to resolve those conflicts first and then merge. Git will put some <<head comments in the code which will help to understand what git is suggesting and then with manual effort we can get in new lines or remove lines as per our final code.

After resolving conflicts then again commit new changes and then push.

Cherry pick

Sometimes we only need few commits to be merge into other branch so cherry pick we use to do the same. You need to checkout into the branch where you want changes to pull. And then run the below command

git cherry-pick commit_id

Git is smart so with the help of commit id it will find out automatically from which branch the changes needs to pull.

Thank you for reading.