We need a few specific GIT commits to be merged unto the production branch, but the issue was the branch is way ahead from the production since it was our development branch. So I was tasks to cherry pick a few commits from a that branch. It was quite simple task but a very tedious one when you already done 20 commits during the course of your development. So we come up a way to package this commits to just one commit.
Consider Branch-A as our dev branch where we did our changes that we want to extract and Production-A as our production branch that we are merging these commits into.
Step 1. First things first, You need to identify the point in history of Branch-A before the changes were mande. This will serve as a point of reference and once you identify it, create a branch on that commit under Branch-A and letâ€™s name it Branch-A-clean.
Step 2. Once you have the branch make sure you checked it out and that the current branch is Branch-A-clean, and then merge in Branch-A into it. This action will create a single commit with all the changes from Branch-A into Branch-A-clean.
Step 3. Make sure that all the files you changed are in that single commit, at this point you can justify where would it conflict in my case I usually do a quick Diff under bitbucket. One thing my colleague did raise is to check for files that is timestamp sensitive a good example are Doctrine Migration scripts, where a few Database update might happen first before a certain other updates.
Step 4. If you are confident with the commit you can now cherry pick that single commit and merge/pull-request it into the Production-A Branch.
This will have a big chance that it may cause good ole conflicts as expected if your changes clashed with other changes on the same files/folders.