98

I'm using Visual Studio 2013's Git support to work on a private GitHub repository. I have permission to commit to it. I want to switch branches, but when I go to the Branches view, the only branch in any of the lists (branch drop-down, published branches, merge tool) is master. Other branches show up in GitHub, GitHub for Windows, and TortoiseGit. So I know they're there and I have access.

Any ideas why I can't see other branches in Visual Studio?

enter image description here

I'm running Visual Studio 2013 Update 2.

Community
  • 1
  • 1
Vimes
  • 10,577
  • 17
  • 66
  • 86
  • 2
    Visual Studio does not show *remote* branches in the branches drop-down. Make sure that you have created a local branch - by doing so, it will set this up to correspond to the remote branch. (Which is to say, it will appear in "published branches"). If you *have* done that, can you post your `.git/config` from that repository? – Edward Thomson Jul 23 '14 at 23:55
  • Ah, that was it! Post as an answer and I'll mark it. Thanks! – Vimes Jul 24 '14 at 16:36
  • 2
    do a Fetch/Pull on the master first prior of creating a local branch and you should be able to see the remote branches in the drop down list `origin\branchname` according to the image bellow i'm using VS2013 Update 5 – Nerdroid Aug 12 '15 at 23:08

1 Answers1

151

The branch dropdown will only show local branches, it will not show remote branches. You should create a new local branch to track that remote branch. Simply click the New Branch dropdown, and you will see all the remote branches:

enter image description here

Once you've done that, this will appear as a "published branch" allowing you to push and pull to it.

Vimes
  • 10,577
  • 17
  • 66
  • 86
Edward Thomson
  • 74,857
  • 14
  • 158
  • 187
  • 13
    Note that this is a little difficult to find; we're working on improving the accessibility of this. – Edward Thomson Jul 24 '14 at 16:56
  • Sweet, thanks. Ya, I was previously using the GitHub for Windows client, which hides the distinction in a very nice UX. – Vimes Jul 24 '14 at 19:28
  • 9
    What triggers visual studio to find new remote branches? I have it pointed at a git repo, I create a branch on that rep or a coworker creates one. If I go to the new branch drop down, nothing new shows. – MattK Aug 28 '14 at 21:08
  • 13
    @MattK You need to fetch from the server, either in Visual Studio or running `git fetch` on the command-line. – Edward Thomson Aug 28 '14 at 22:07
  • 10
    I had the same issue as MattK. It was resolved by clicking Fetch on a branch under Unsynced Commits. This should really be within the New Branches section and/or be completed when the Refresh icon is clicked. – ScubaSteve Dec 05 '14 at 14:30
  • @EdwardThomson, Just FYI, there's been a steady stream of upvotes on this question/answer for 10 months and counting. I hope the fix hasn't fallen through the cracks. – Vimes May 20 '15 at 19:14
  • 2
    @JVimes Indeed. We've changed this experience in VS 2015 - we think for the better - please do give us feedback if you have the opportunity! – Edward Thomson May 20 '15 at 19:16
  • @EdwardThomson, VS 2015 was great once I realized that the tree was of branches, not files. But at a glance I thought it was files and spent minutes hunting. Maybe rename "Active Git Repositories" to "Repositories and Branches". I'll report this with the smile/frown tool. Thanks! – Vimes Aug 13 '15 at 17:18
  • I have created a new branch on visual studio online and it is not listed on Visual Studio 2015 Enterprise. Any advice? – VansFannel Aug 19 '15 at 16:59
  • 2
    I had to 'fetch' first as @MattK indicated. I had already tried creating the branch in this manner and didn't see it. It would be helpful if the answer included this step (first fetch, then create new branch...) instead of having to go through the comments. – BlackjacketMack Dec 21 '15 at 15:29
  • 2
    @MattK with one of the most useful comments I have ever seen. I love Visual Studio but the difference between a local and remote branch needs to be identified much better in the UI. – Issa Fram Dec 30 '15 at 21:04
  • 1
    Note on vs2015. I attempted Right Mouse Click | Fetch on the remote master branch to no avail. Running git fetch command line from the root directory of the solution did work. – Bleeped Jun 21 '16 at 15:19