Connecting to a remote Git branch from Visual Studio

When you first connect to a Git Repository in Visual Studio, you are going to be defaulted to cloning the Master remote branch.  But what if you want to work on a different branch?    You’ll need to clone that branch before you start working on it.  If you look at the branches tab in Team Explorer, you probably only see the one branch and see no sign of the other branches:
image

But in Visual Studio Online, I see 3 remote branches:
image

Well, before you can see the branches locally, you need to create a local tracking branch for the remote branch.  You could do this with command-line: git branch dev –track origin/dev

You can also do this right from Visual Studio.  First, click on “New Branch”
image

Then select the remote branch from the drop-down list, this will auto-populate the branch local name. You can change the name of the local branch if you want since it’s just a mapping:
image

image

And click on Create Branch.

Now you have your local branch and you can start making changes and pushing/pulling with your remote branch.
image

If you want to get started with Git and be successful with it, while staying in Visual Studio, I created a Pluralsight course that you may want to check out: Git for Visual Studio Developers.

About esteban

Esteban is the Founder and Chief Technologist at Nebbia Technology, an ALM consulting and Azure-powered technology company. He is a software developer with a passion for ALM, TFS, Azure, and software development best practices. Esteban is a Microsoft Visual Studio ALM MVP and ALM Ranger, Pluralsight author, and the president of ONETUG (Orlando .NET User Group).

3 thoughts on “Connecting to a remote Git branch from Visual Studio

  1. Dew Drop – December 11, 2014 (#1913) | Morning Dew

    […] Connecting to a remote Git branch from Visual Studio (Esteban Garcia) […]

  2. vishal yadav

    Thank you very much!!
    Helped me a lot

  3. Bob

    thanks man this is amazing


Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human? *