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:
But in Visual Studio Online, I see 3 remote branches:
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”
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:
And click on Create Branch.
Now you have your local branch and you can start making changes and pushing/pulling with your remote branch.
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.