By using git cherry-pick, I've been trying to specifically merge the last commit from one branch to another. But it always results in a merge conflict, when it actually shouldn't. Following is what I've been doing, and it always results in conflicts.
- Initiate a new repository, and commit a fresh new file on master branch. The file would have the following content -
MASTER - 1st commit
- Checkout to a new branch called testing, and make the following changes to the file, and commit again.
MASTER - 1st commit : TESTING 1st commit
3.) Make further changes, on the same line of the file and commit again. So at the end, the file contents would look like the following.
MASTER - 1st commit : TESTING 1st commit : TESTING 2nd commit
Now, this would leave us with 1 commit on master branch, and 2 commits on testing. So if we were to checkout master and do a git merge testing
, then since, there's a direct path between the last commit from master and the last commit to testing, therefore, git will use the fast forward technique, and without any merge conflicts, it will directly incorporate changes from testing to master. So my question is why this isn't the case when I try git cherry-pick testing
(i.e merging the last commit from testing to master, which in turn has a direct path to it). If I'm being wrong here, then please suggest, what would be the correct way to do this.