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.

12 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

  4. shahab

    Thank you So much.. So much helpful and indeed clearly explaind.

  5. JimPhifs

    Go to this site to get 1cooking fever free gems

    krtd23las
    Cooking Fever is more fun when you have unlimited diamonds.If you love mobile games like this you should check out this website

  6. JimPhifs

    I am sure you will like this 1website

    k23lartds11
    Cooking Fever is a whole lot more fun when you have unlimited diamonds.If you enjoy phone games like this you need to check out the guide above


Leave a Reply

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