Working with Git Branches in Visual Studio 2019

User Review
0 (0 votes)

Continuing our previous posts, let us now see how we can work with branches within Visual Studio 2019.

Branches give the option to isolate the work from the original code base, this way we could have a developer(s) working on bug fixes, new features etc. which then can be merged back to the master branch later.

Open the Branches page in Team Explorer and click on the New Branch option.

Here we have created a new branch name MyFirstBranch from the master branch, and have also selected the option Checkout branch to work with that branch.

Create Branch creates the new branch as shown below.

To navigate to the branches page of Team Explorer, we can also use the Status bar of Visual Studio

Now let us make some changes in the program.cs file in the new branch created.

Do Commit and Push

From the team explorer, Branches page, we can see that the new branch has been added in the remote repository after commit.

To merge changes back from this new branch to the master branch, click on the master branch and select Merge option in the Branches page

  • Merge from Branch: MyFirstBranch
  • Into current branch: master.

As we have selected the option Commit changes after merging click on Merge pushes and sync the changes in the master branch in the remote repository as shown below.

We also have the options of deleting the branches as shown below, if they are not required anymore.

In this post, we saw how to work with Branches and how to merge it back to the base code.

Hope it helps..

Leave a Reply