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

95,298

Solution 1

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

Solution 2

You can Fetch in Visual Studio Team Explorer.

View => Team Explorer

enter image description here

Solution 3

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.

Solution 4

If you are using the 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

Solution 5

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.

Share:
95,298
Dan
Author by

Dan

Contracting in anything interesting with Microsoft technologies, primarily middle/back-end in C#, BizTalk, Azure, SQL Server, WCF, SSIS, etc. Currently working at Wokingham Borough Council on integrations using Dynamics CRM Online, Azure Service Bus and various back office systems. Please feel free to contact me if you've got an interesting project ...

Updated on April 29, 2022

Comments

  • Dan
    Dan about 2 years

    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.

  • Dan
    Dan almost 7 years
    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.
  • Dan
    Dan over 6 years
    The only way I've found to work is answer using the command line ... git fetch --prune --verbose
  • Dan
    Dan over 6 years
    The only way I've found to work is answer using the command line ... git fetch --prune --verbose
  • Admin
    Admin almost 6 years
    This answer helped me. After doing a Sync the branch list was refreshed. Thanks Daniel
  • openshac
    openshac over 5 years
    Agreed, @TerraElise 's answer indicates that you have to have pruning turned on for this to work.
  • Adam Cox
    Adam Cox over 5 years
    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...
  • user423430
    user423430 over 3 years
    Sweet action jackson it worked! Thanks, you're my hero.
  • Eric Aya
    Eric Aya over 3 years
    This has already been suggested, look at Marina's answer for example.
  • r3mark
    r3mark about 3 years
    VS 2019: Tools > Options > Source Control > Git Global Settings