How do I refresh branches (local/remote) in Visual Studio when using Git?

According to this blog post, you can set a git property via

git config remote.origin.prune true

that will remove deleted branches from your list when you perform a fetch.


If the branch has been deleted on the server side, try in command line (since such a "button" doesn't seem to exist directly in Visual Studio):

git remote prune origin --dry-run

(remove the --dry-run option to actually delete the local branches)

Delete the corresponding local branch as well git branch -d aBranch.

Then restart your Visual Studio, and check it picks up the updated branch list. (comments mention you don't have to restart/refresh VS)

Note: I mentioned before in 2013 the configuration

git config remote.origin.prune true

That would automate that process, and seems to be supported by Visual Studio, as mentioned below by yaniv.


On VSCode, try also to activate the setting "Git: Prune on Fetch"

"git.pruneOnFetch": true

From : "Refresh git remote branches in Visual Studio"

You can configure git to do this automatically on fetch/pull running with this command:

git config remote.origin.prune true –global

Update:

Visual Studio 2017 version 15.7.3 and above you can do it using the UI :

  1. In Team Explorer , click the Home then Setting: enter image description here

  2. Select Global settings

  3. Change "Prune remote branches during fetch" to "True"