Saturday, December 20, 2014

Merging Branches

Merging is another important feature of any version control system. Merging involves joining the changes from 2 branches.

In general a base [master] branch is maintained, when a major change is to be done a branch is created from the master branch, all the changes are done in the branch and tested. Once the version of the code in the branch is certified as stable it will be merged into the main branch.

The current branch will be the target branch of the merge, when you want to merge changes from an iteration branch to the main branch you will have to switch (Checkout) into the main branch and then select the iteration branch which you want to merge with the main branch.

Follow the below steps to perform a branch merge in SourceTree

1.    Open source Tree.
2.    Before merging, make sure that you Checkout (switch) to the target branch to which the changes should be merged.
3.    Here we will merge the changes from the GitCommands branch into the master branch, so we will first Checkout to the master branch.

4.    Click on the Merge option from the Toolbar.

5.    In the pop-up, select the iteration branch which you want to merge with the main branch. In our case we will merge the GitCommands branch with the master branch, so let us select the GitCommands branch.

6.    Notice, that we selected the option “Commit merge immedietly”, click OK
7.    The changes from the iteration branch will get merged with the master branch.
8.    In our case the new file “Git Commands.docx” which we added to the branch will get added to the master branch, also the new file will get downloaded to the local working folder.
9.    The changes of merger are only in the local repository, if we need these changes to be reflected in the remote repository then we will have to explicitly push these changes using the Push option.
10. You can also merge a branch into the current Branch by right clicking on the branch which is to be merged and selecting the “merger” option.

Search Flipkart Products: