How to merge two separate branches using Tortoise Git client

Here I am going to show you how to merge two separate branches into one using tortoise git client. Generally you or development team need to maintain separate line of development in different branches. So at some later point of time you need to merge your changes into another branch.

Your team may manage different branches, such as feature branch for developing your features and changes are committed into feature branch and finally merged each feature branch into development branch and development branch to master branch that is generally remain idle for most of the time and this branch is said to be stable branch.

There might be another branch called release branch which is created from master branch and might be used to deploy on your different environments.

Let’s say you are doing code changes in your feature branch and this feature branch you have created from development branch (for example, development which is created from master branch django-mysql). You need to do right-click and click on Git Clone. You have cloned this feature branch using tortoise git client into your local system.

Then you need to put the git URL that ends with .git and put it in the URL: section as highlighted in the below image. You can also browse the remote branches after putting the git URL using the Browse button given next to the input box. Then you need to select the local folder where you want to clone or checkout. Next you have to input the feature branch (for example, feature/django-mysql-req-1234) in the Branch section. Finally you hit OK.

So your feature branch has been cloned into your local system. Now let’s assume you have made your changes into feature branch and you want to merge changes into development branch. Next step would be to clone or checkout the development branch (for example, development) into your local in the same way you cloned the feature branch.

Make sure you committed your changes into feature branch before you merge the changes from feature branch to development branch.

Note that the merging always takes place within a working tree. If you want to merge changes into a branch, you have to have a working tree for that branch checked out.

By this time I assume that you have committed and pushed your changes to your remote feature branch. Let’s say you want to merge your changes from feature branch (feature/django-mysql-req-1234) to development branch (development).

So you need to do right-click on the django-mysql (it is my development branch) then you need to click on Merge as highlighted in the below image.

merge two separate branches using tortoise git client

Now a popup will come up and you need to select the remote feature branch (for example, remotes/origin/feature/django-mysql-req-1234). By default it selects the remote development branch (remotes/origin/development) and you need to change it to feature branch because you want to merge feature branch into development branch. Then hit Ok. If there is no conflict then you are good to go.

Finally you have to push the merge to the remote repository. because whatever you have merged into your development branch, it is in your local development branch. So push the changes using the option from tortoise git, Tortoise Git -> Push.

Now if you had any conflicts while merging then you have to resolve conflicts before pushing the changes.

That’s all about merging the code from one branch to another branch.

Leave a Comment