Git merge source branch followed by destination branch.

  • git merge source_branch destination_branch

 

First you have to move to destination branch - master in our case

 

 

Check if there any difference in master and develop branch

And We can see these are the two files missing basic.txt and second.txt. These are the two files missing in master branch

  •  – means missing from master branch

 

 

 

 

Method 1: COMPLETE MERGE (All Commits)

Merge these 2 changes into your master branch

Since we already on destination branch, so run the merge command with source branch

 

 

 

 

Method 2 A. Cherry Picking merge (Specific Commit) - CLI Command

Imagine numerous features are created in dev branch like feature 1 and feature 2. Now out of this, only one commit still needs to be pushed into release branch and subsequently to the production branch.

What happens when we use regular git merge? All differential modifications will go into my release branch, which we don't want.

 

Git provide the concept of Cherry picking exists to avoid this
Cherry picking is a method for selecting specific commits.

 

Lets do some change in our development branch

commit your changes in develop branch

 

Lets add one more file and make a separate commit 

 

Git log your changes

 

 

For Cherry Picking merge- move to destination branch first

 

Cherry pick your specific merge using first 7 digit of your commit
lets pick the commit for 3 files and skip the commit of 4th file

 

Check our Physical files

featureone, featuretwo, featurethree is showing but featurefourth is not picked

 

 

 

Method 2 B. Cherry Picking merge (Specific Commit) - DevOps UI

  • At DevOps, got to specific commit you want to cherry pick 
  • Select Target branch
    • A Temporary branch is created below along with a PR
      • Click Cherry pick button
      • A New PR is created for this change
        • Create this PR
        • Complete this PR
        • Deleting the temporary branch. Because the purpose of the temporary branch was only to create a PR.
  • Cross check commits for featurenine branch

 


Related Question