Visual Studio 2015 How to merge a branch into master?

Lord of Scripts picture Lord of Scripts · Feb 3, 2017 · Viewed 58.4k times · Source

I am new to GIT, so far I had been using Visual Studio Online TFS for my version control and I am the only developer. When I created my last project I was kind of mislead into thinking GIT was the best option for this.

So I checked-in my master. Then when I was going to work on a Feature I read I had to create a branch (this was not necessary in TFS) so I created "development_print" as a new branch and worked on my feature.

Now my feature is complete but I don't know how to merge it back into master. I am not interested in multiple branches at the moment, just want my new feature merged into master and remain with master.

In VS there is a merge branch option but it only allows me to merge into development_print (I want my feature into master!) so it does not let me set Into Current Branch and for Merge From Branch shows:

  • Development_print
  • master
  • origin/development_print
  • origin/master

which is kind of confusing? it seems all backwards. So how do I get out of this mess without losing all the work I did on the feature?

Answer

Marina Liu picture Marina Liu · Feb 4, 2017

The way to merge development_print branch into master branch as below:

VS -> Team Explorer -> Branches -> double click master branch -> Merge -> select development_print for Merge from branch -> Merge.

The select box shows:

development_print
master
origin/development_print
origin/master

That means you have branches development_print and master for both local and remote. origin/ means branches exist in remote.

If you don’t want the development_print branch after merging you can delete it for local and remote:

Team Explorer -> Branches -> select development_print -> right click -> Delete -> select development_print under remotes/origin -> Delete Branch From Remote.