Deleted origin git branches aren’t removed from VS2015 git

We use a gitflow-esque branching strategy where a new branch is created for each feature being worked on. Once the code is sync’d to the server and the PR is approved, the code is merged down into our main development branch and the feature branch is automatically deleted from origin by Visual Studio Team Services. This results in a lot of branches that we work on. One issue that popped up was that despite the branches being deleted from origin, we’d still see the branches within Visual Studio 2015’s git Branches pane.
Too many branches

Of all the branches listed in the remotes/origin/feature folder, only 2 of them still exist at origin. Fetching from within VS2015 does not remove the entries which are no longer valid. The issue stems from VS2015 not supporting remote origin pruning. An easy workaround is to go to the command prompt and run:

git config remote.origin.prune true

From that point on, any fetch commands performed by git will also prune any branches that are no longer valid from the remote/origin list. Once this option is turned on, we can perform a Fetch from within Visual Studio and voila!
Much more concise

We now only see the branches that still exist on origin.

Leave a Reply

Your email address will not be published. Required fields are marked *