If you’ve been using Git from within Visual Studio 2017 you might be aware of the fact that when performing a fetch it would not automatically prune your local list of branches that no longer exist on the server. Typically you would have to open up a Command Prompt and run the following command to cleanup your list of branches that exist on the remote:
> git remote prune origin
Well now with Visual Studio 2017 Update 5 you can now configure your global and repository settings to prune your local list of branches on every fetch. Let’s take a look at how you can configure this.
First download and install Visual Studio 2017 Update 5. You can do this from within Visual Studio under the Tools menu:
Once you have Visual Studio 2017 Update 5 installed, go to the Team Explorer pane and click on Settings where you can configure your default behavior for your Global and/or Repository Settings:
Now you can change the setting to prune remote branches on every fetch. In my opinion this should be the default value.
Another nice addition to the Git settings in Visual Studio 2017 Update 5 is the ability to Rebase your changes when you pull. I’ll explore that in a future post.
In summary when enabling the prune on every fetch, this means your local list of branches is always up-to-date with the remote. Pruning will cleanup and remove your local tracking branches that no longer exist on the server.