154

I have created a new Git repository on Visual Studio online. I have cloned on my computer and I have added it a project. After that, I have created a new branch called develop on Visual Studio online, and I have tried to check it out creating a new local branch but it doesn't appear on Team Explorer.

This is my Visual Studio online: enter image description here

And this is Visual Studio 2015 Team Explorer: enter image description here

Why develop branch doesn't appear on Team Explorer?

VansFannel
  • 45,055
  • 107
  • 359
  • 626

5 Answers5

329

You can now do this in Visual Studio by going to the Synchronisation tab (Sync in the Team drop down menu) and clicking Fetch at the top.

Choose Sync from the menu, hit fetch

Dr Rob Lang
  • 6,659
  • 5
  • 40
  • 60
  • 13
    Thx! Just a small remark, don't you find it confusing that it states: Branch master? I then always things I am performing the action on the master branch – Kenny Saelen Jun 21 '17 at 08:17
  • 3
    Agreed! That is odd. – Dr Rob Lang Jun 21 '17 at 08:57
  • 6
    Also note that after you click Fetch, no notification that anything has occurred is displayed. You simply go to branches afterwards and will see the missing branch. – Sabel Jan 23 '18 at 15:10
  • 9
    This should really be in the branches section and not under sync. – gsharp Jul 13 '18 at 11:08
  • 13
    Yeah, it'd be nice if the 'refresh' button on the Branches tab just did a fetch too. That was my expectation. – Michael Hawker - MSFT Jul 26 '18 at 00:50
  • Its worked, Thanks. I was selected another branch and refreshed then its not apprear, but when I changed branch to Master and refreshed then it appears. – Kishor T Aug 30 '18 at 09:27
  • This doesn't work for me. It's not pulling in any of my remote feature/* branches – Ryan Dec 26 '18 at 21:14
  • Thanks all. The sync worked for me but I tried it on another VM and the pull also worked. – rhoonah Sep 06 '22 at 16:06
  • It fixed it. But why. It seems like VS should work more intuitively. Like, when you click the Branches icon, or the remotes drop down, it should pull automatically. +1 for the answer, -1 assessed to whoever is currently designing VS. – Jason P Sallinger Jan 30 '23 at 18:22
43

I have solved my problem opening a Git Command Prompt (following this instructions), and doing a git fetch to retrieve the new branch.

VansFannel
  • 45,055
  • 107
  • 359
  • 626
  • 3
    Doing a "pull" inside of Visual Studio should have achieved the same result if you are on the latest updates. – MrHinsh - Martin Hinshelwood Aug 20 '15 at 19:28
  • 2
    I have the same problem and I can confirm that - After pulling in the team explorer the missing branch appear. Thanks! – Lion Sep 27 '15 at 10:38
  • The problem here is that your local client doesn't know when the server updates; you have to pull data from it for the server to give you data. Hence a fetch is needed if a new branch is made on the server (one that you didn't make locally). If you understand client/server then it shouldn't be too.. unbelievable. – Dagrooms Apr 24 '17 at 20:31
  • I tried this, and hundreds of branch refs were downloaded, but when returning to VS2017 (latest updates) the branches are still not visible on the branches list. – Ryan Dec 26 '18 at 21:15
0

Please check the casing of the branch name.
Looks like when the visual studio first downloads the branch locally, it changes the folder name to lowercase when the local repo is created. However, for future pulls it does a case-sensitive search on the remote repo, causing a mismatch!

General guidance: If you are using a folder name for the branches, make sure you are using lowercase.

Arulvel
  • 69
  • 3
0

Sometimes simply clicking the fetch button will not work if there are many remote branches and depending on how it's setup. If standard fetch doesn't work try running git fetch --all from the package manager console or command line.

SendETHToThisAddress
  • 2,756
  • 7
  • 29
  • 54
-1

I had the exact opposite issue (more or less): I could see the branch in Visual Studio, but it wasn't on the remote server.

Trying to delete it (from remote) yielded this error:

Error encountered while pushing to the remote repository: Git failed with a fatal error. PushCommand.ExecutePushCommand

Here's how to fix it (tested in VS 2017):

  1. In Visual Studio, double click on your "rogue" remote branch;
  2. VS should have now created a local branch from it;
  3. Right click on the local branch, select "Unset remote branch";
  4. Right click on the local branch, select "Push branch";
  5. You should now have a true corresponding remote branch;
  6. Delete the remote branch, then the local branch.

Hopefully it will help someone who ends up on this thread having the same issue as me.

kk.
  • 3,747
  • 12
  • 36
  • 67
XYZ
  • 39
  • 4