Monday, November 26, 2012

Cherry-Picking specific commits from one branch to another

Say, for example you are working with two different branches. Dev-4.0 and Dev-5.0.

And you have made few changes/fixes in Dev-4.0 branch and now you want to bring those changes in to the Dev-5.0 branch.

GIT provides cherry-pick command to do that.

1. Go to Dev-4.0 branch and identify the commit id's which need to be cherry-picked.
ex: Below the commit id's for my changes in Dev-4.0 branch.


2. Go to Dev-5.0 branch and fire the following command.

> git cherry-pick  8ae534e23d82070cdaaea4913415678affdab44b

this will bring all your commit changes from Dev-4.0 to  Dev-5.0

If you have any conflicts during this time.
- Resolve the conflicting files
- Once you have resolved the issues, add them to git if it's not added.
- Commit the modified files.

Otherwise git automatically commit your changes with cherry-pick command itself, if there are no conflicts occurred.


Now..hope you are good to go!!.

No comments:

Post a Comment