128

How can I refresh the list of remote branches in my Visual Studio Team Explorer panel?

In the Visual Studio 2017, Team Explorer, Branches panel, I could see the 10 or so branches in our VSTS instance.

Then in Chrome, I deleted some of the older branches and created a new branch.

Switched back to VS 2017, but the list of remotes/origin branches still shows the old list, and I can't find anyway to refresh it.

I tried changing to a different repo, the F5 Refresh on the team explorer header, I even closed and reopened VS 2017 ... but nothing refreshes the list to match what VSTS portal shows

SteveC
  • 13,636
  • 21
  • 86
  • 155

8 Answers8

197

If you want Visual Studio 2017 to ALWAYS prune on fetch (I do, I add and remove a LOT of branches for UI work), once you install 3rd party Git (can do from Settings within Team Explorer, Git section) there will be a new option in Global Settings (also in Git section) to 'Prune remote branches during fetch' which you can set to True. I did not have this option before updating my VS to 15.5 (I was on 15.0).

Location of prune setting

TerraElise
  • 2,404
  • 1
  • 10
  • 13
  • 2
    FYI.. If your settings does not include the Team Project nodes (only the Git), then you are not connecting to a project - Connection Manager > Connect to a Project... – Adam Cox Nov 01 '18 at 13:36
  • VS 2019: Tools > Options > Source Control > Git Global Settings – r3mark Mar 19 '21 at 01:11
65

You can Fetch in Visual Studio Team Explorer.

View => Team Explorer

enter image description here

Erik Hakobyan
  • 954
  • 7
  • 15
44

In your local repo directory, you should use git fetch -p (or git fetch --prune) command. Then you will find the deleted branches from remote won't showed in remotes/origin in VS Branches panel.

This is because git fetch won't check the tracking references exist or not from remote repo. But for git fetch -p, it will check if the tracking references exist or not and delete non-existing ones before fetching.

SteveC
  • 13,636
  • 21
  • 86
  • 155
Marina Liu
  • 32,805
  • 4
  • 48
  • 60
6

You have to fetch first. All Visual Studio is doing is interacting with your local repo. If you don't fetch the branches from the remote, it won't know they're present.

Daniel Mann
  • 49,975
  • 11
  • 87
  • 105
  • 1
    I don't think this actually answers my question ... In the Visual Studio 2017, Team Explorer, Branches panel, I could see the 10 or so branches in our VSTS instance. Then in Chrome, I deleted some of the older branches and created a new branch. Switched back to VS, but the list of remotes/origin branches still shows the old list. – SteveC Jul 20 '17 at 07:05
  • The only way I've found to work is answer using the command line ... git fetch --prune --verbose – SteveC Nov 21 '17 at 08:46
  • This answer helped me. After doing a Sync the branch list was refreshed. Thanks Daniel –  Jun 21 '18 at 09:50
2

Find the remote branch in remotes -> origin, then double-click that branch to get it selected locally. Now you can fetch/sync/etc.

Fetching a remote branch

Sean
  • 12,296
  • 9
  • 66
  • 104
1

I use Visual Studio 2015 and I couldn't find most of the setting options mentioned in the other answers. Here is something that actually worked for me :

Go to Team Explorer tab--> Click on the "Home" button --> Sync --> Click on the "Sync" link

This is make Visual Studio to synchronize the branches between the Repository and your local version.

Ajay Meda
  • 61
  • 3
1

If you use then new "New Git User experience" (Enabled by Tools -> Options -> Environment -> Preview Features -> having "New Git User experience" checked).

Then the steps to get to the same location as referenced by TerraElise answer above would be going to "Git" option on the top menu pane -> settings to the same location to set your "Prune on fetch" option.

enter image description here

enter image description here

Michael Edmison
  • 453
  • 4
  • 11
-2

you can use the git command : git fetch -p

  • This has already been suggested, look at [Marina's answer](https://stackoverflow.com/a/45209983/2227743) for example. – Eric Aya Feb 04 '21 at 14:27